void MSocketThread::run() {
MSocket mSocket;
if ( 0 != socketDescriptor ) {
if ( !mSocket.setSocketDescriptor(socketDescriptor) ) {
std::cerr << "Failed to set SocketDescriptor." << endl;
}
/* Output who joined the server */
QString ipString
(tr
("<font color=blue>%1 has joined.</font>").
arg(ipaddress.
toString()));
emit relayIncomingText(ipString);
}
connect(&mSocket, SIGNAL(connected()),
this, SIGNAL(connectionEstablished()));
connect(&mSocket,
SIGNAL(inboundText
(QString)),
this,
SIGNAL(relayIncomingText
(QString)));
connect(this,
SIGNAL(sigSend
(QString)),
connect(&mSocket, SIGNAL(error()),
this, SIGNAL(quit()));
connect(&mSocket, SIGNAL(disconnected()), this, SLOT(quit()));
if ( 0 == socketDescriptor ) {
mSocket.connectToHost(ip, port);
}
exec(); //Begin event loop.
}
void MSocketThread::run() {
MSocket mSocket;
if ( 0 != socketDescriptor ) {
if ( !mSocket.setSocketDescriptor(socketDescriptor) ) {
std::cerr << "Failed to set SocketDescriptor." << endl;
}
/* Output who joined the server */
QHostAddress ipaddress = mSocket.peerAddress();
QString ipString(tr("<font color=blue>%1 has joined.</font>").arg(ipaddress.toString()));
emit relayIncomingText(ipString);
}
connect(&mSocket, SIGNAL(connected()),
this, SIGNAL(connectionEstablished()));
connect(&mSocket, SIGNAL(inboundText(QString)),
this, SIGNAL(relayIncomingText(QString)));
connect(this, SIGNAL(sigSend(QString)),
&mSocket, SLOT(send(QString)));
connect(&mSocket, SIGNAL(error()),
this, SIGNAL(quit()));
connect(&mSocket, SIGNAL(disconnected()), this, SLOT(quit()));
if ( 0 == socketDescriptor ) {
mSocket.connectToHost(ip, port);
}
exec(); //Begin event loop.
}
To copy to clipboard, switch view to plain text mode
Bookmarks