void Client::connectToServer(LoginHandler *loginhandler) { Q_ASSERT(_isloopback); TcpServer *server = new TcpServer(this); _server = server; _isloopback = false; m_sessionId = loginhandler->sessionId(); // target host/join ID (if known already) connect(server, SIGNAL(loggingOut()), this, SIGNAL(serverDisconnecting())); connect(server, SIGNAL(serverDisconnected(QString, QString, bool)), this, SLOT(handleDisconnect(QString, QString, bool))); connect(server, SIGNAL(serverDisconnected(QString, QString, bool)), loginhandler, SLOT(serverDisconnected())); connect(server, SIGNAL(loggedIn(QString, int, bool)), this, SLOT(handleConnect(QString, int, bool))); connect(server, SIGNAL(messageReceived(protocol::MessagePtr)), this, SLOT(handleMessage(protocol::MessagePtr))); connect(server, SIGNAL(expectingBytes(int)), this, SIGNAL(expectingBytes(int))); connect(server, SIGNAL(bytesReceived(int)), this, SIGNAL(bytesReceived(int))); connect(server, SIGNAL(bytesSent(int)), this, SIGNAL(bytesSent(int))); connect(server, SIGNAL(lagMeasured(qint64)), this, SIGNAL(lagMeasured(qint64))); if(loginhandler->mode() == LoginHandler::HOST) loginhandler->setUserId(m_myId); emit serverConnected(loginhandler->url().host(), loginhandler->url().port()); server->login(loginhandler); m_lastToolCtx = canvas::ToolContext(); }