//------------------------------------------------------------------------------
bool ClientLogon::handlePacket(Packet * packet)
{
    RakNet::BitStream stream(&packet->data[1], packet->length-1, false);
    switch (packet->data[0])
    {
    case ID_DISCONNECTION_NOTIFICATION:
        if (!suicide_scheduled_)
        {
            // something is wrong if we are disconnected without
            // receiving either session key or authorization
            // failed messages...
            onConnectFailed("Connection to authentication server closed unexpectedly.");
        }
        break;
    case ID_CONNECTION_REQUEST_ACCEPTED:
        sendCredentials(packet->systemAddress);
        break;

    case ID_CONNECTION_ATTEMPT_FAILED:
        onConnectFailed("Failed to contact authentication server.");
        break;
    case ID_ALREADY_CONNECTED:
        onConnectFailed("Already connected!?");
        break;
    case ID_NO_FREE_INCOMING_CONNECTIONS:
        onConnectFailed("Server is busy. Try again in a moment.");
        break;
    case ID_CONNECTION_BANNED:
        onConnectFailed("You have been banned from the authentication server!");
        break;
    case VHPI_VERSION_MISMATCH:
        onConnectFailed("Client is not up to date.");
        break;
    case VHPI_TYPE_MISMATCH:
        onConnectFailed("Target server is not a valid authentication server.");
        break;

            
    case ID_RSA_PUBLIC_KEY_MISMATCH:
        onConnectFailed("Our public key stored for the ranking server is out of date.");
        break;
            
    case RPI_SESSION_KEY:
        onSessionKeyReceived(stream);
        break;

    case RPI_AUTHORIZATION_FAILED:
        onAuthorizationFailed(stream);
        break;
            
    default:
        return false;
    }

    return true;
}
示例#2
0
文件: client.cpp 项目: lukitree/Chat
Client::Client(QWidget *parent)
	: QMainWindow(parent)
{
	ui.setupUi(this);

	tcpSocket = new QTcpSocket(this);
	promptConnect = new ConnectDialog(this);

	credentialsSent = false;

	ui.actionDisconnect->setDisabled(true);
	ui.actionReconnect->setDisabled(true);

	connect(tcpSocket, SIGNAL(readyRead()), this, SLOT(getMessage()));
	connect(tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(displayError(QAbstractSocket::SocketError)));
	connect(tcpSocket, SIGNAL(connected()), this, SLOT(sendCredentials()));
	connect(tcpSocket, SIGNAL(connected()), this, SLOT(onConnect()));
	connect(tcpSocket, SIGNAL(disconnected()), this, SLOT(onDisconnect()));
	connect(ui.userList, SIGNAL(itemDoubleClicked(QListWidgetItem*)), SLOT(whisperOnClick(QListWidgetItem*)));
}
示例#3
0
void startClient() {
	connectToServer();
	sendCredentials();
	acceptInput();
}