diff -r eacf1b165d2d -r f19bbd639726 mapeditor.cpp --- a/mapeditor.cpp Wed Jun 20 11:58:47 2007 +0000 +++ b/mapeditor.cpp Thu Jun 21 14:27:46 2007 +0000 @@ -4041,10 +4041,25 @@ } } -void MapEditor::testFunction() +void MapEditor::testFunction1() { + + tcpServer = new QTcpServer(this); + if (!tcpServer->listen(QHostAddress::Any,54321)) { + QMessageBox::critical(this, tr("Fortune Server"), + tr("Unable to start the server: %1.") + .arg(tcpServer->errorString())); + close(); + return; + } + connect(tcpServer, SIGNAL(newConnection()), this, SLOT(newClient())); + if (debug) + cout<<"Server is running on port "<serverPort()<peerAddress().toString().ascii()<write (block); + } } void MapEditor::contextMenuEvent ( QContextMenuEvent * e ) @@ -4735,6 +4767,27 @@ mainWindow->fileSave (this); } +void MapEditor::newClient() +{ + QByteArray block; + QDataStream out(&block, QIODevice::WriteOnly); + out.setVersion(QDataStream::Qt_4_0); + out << (quint16)0; + out << xelection.getSelectString(); + out.device()->seek(0); + out << (quint16)(block.size() - sizeof(quint16)); + + QTcpSocket *newClient = tcpServer->nextPendingConnection(); + connect(newClient, SIGNAL(disconnected()), + newClient, SLOT(deleteLater())); + + cout <<"ME::newClient at "<peerAddress().toString().ascii()<write(block); + //newClient->disconnectFromHost(); +} /*TODO not needed? void MapEditor::contentsDropEvent(QDropEvent *event) {