当前位置: 首页>>代码示例>>C++>>正文


C++ disconnectClient函数代码示例

本文整理汇总了C++中disconnectClient函数的典型用法代码示例。如果您正苦于以下问题:C++ disconnectClient函数的具体用法?C++ disconnectClient怎么用?C++ disconnectClient使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了disconnectClient函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: disconnect

void ProtocolOld::onRecvFirstMessage(NetworkMessage& msg)
{
    if (g_game.getGameState() == GAME_STATE_SHUTDOWN) {
        disconnect();
        return;
    }

    /*uint16_t clientOS =*/ msg.get<uint16_t>();
    uint16_t version = msg.get<uint16_t>();
    msg.skipBytes(12);

    if (version <= 760) {
        disconnectClient("Only clients with protocol " CLIENT_VERSION_STR " allowed!");
        return;
    }

    if (!Protocol::RSA_decrypt(msg)) {
        disconnect();
        return;
    }

    uint32_t key[4];
    key[0] = msg.get<uint32_t>();
    key[1] = msg.get<uint32_t>();
    key[2] = msg.get<uint32_t>();
    key[3] = msg.get<uint32_t>();
    enableXTEAEncryption();
    setXTEAKey(key);

    if (version <= 822) {
        disableChecksum();
    }

    disconnectClient("Only clients with protocol " CLIENT_VERSION_STR " allowed!");
}
开发者ID:Fir3element,项目名称:tfs12,代码行数:35,代码来源:protocolold.cpp

示例2: getConnection

bool ProtocolOld::parseFirstPacket(NetworkMessage& msg)
{
	if(g_game.getGameState() == GAME_STATE_SHUTDOWN)
	{
		getConnection()->closeConnection();
		return false;
	}

	/*uint16_t clientOS =*/ msg.GetU16();
	uint16_t version = msg.GetU16();
	msg.SkipBytes(12);

	if(version <= 760)
		disconnectClient(0x0A, "Only clients with protocol " CLIENT_VERSION_STR " allowed!");

	if(!RSA_decrypt(msg))
	{
		getConnection()->closeConnection();
		return false;
	}

	uint32_t key[4];
	key[0] = msg.GetU32();
	key[1] = msg.GetU32();
	key[2] = msg.GetU32();
	key[3] = msg.GetU32();
	enableXTEAEncryption();
	setXTEAKey(key);

	if(version <= 822)
		disableChecksum();

	disconnectClient(0x0A, "Only clients with protocol " CLIENT_VERSION_STR " allowed!");
	return false;
}
开发者ID:CkyLua,项目名称:tfs,代码行数:35,代码来源:protocolold.cpp

示例3: getConnection

bool ProtocolOld::parseFirstPacket(NetworkMessage& msg)
{
	if(g_game.getGameState() == GAMESTATE_SHUTDOWN)
	{
		getConnection()->close();
		return false;
	}

	/*uint16_t operatingSystem = */msg.get<uint16_t>();
	uint16_t version = msg.get<uint16_t>();
	msg.skip(12);
	if(version <= 760)
		disconnectClient(0x0A, CLIENT_VERSION_STRING);

	if(!RSA_decrypt(msg))
	{
		getConnection()->close();
		return false;
	}

	uint32_t key[4] = {msg.get<uint32_t>(), msg.get<uint32_t>(), msg.get<uint32_t>(), msg.get<uint32_t>()};
	enableXTEAEncryption();
	setXTEAKey(key);

	if(version <= 822)
		disableChecksum();

	disconnectClient(0x0A, CLIENT_VERSION_STRING);
	return false;
}
开发者ID:AhmedWaly,项目名称:CastOnly,代码行数:30,代码来源:protocolold.cpp

示例4: getConnection

void ProtocolOld::onRecvFirstMessage(NetworkMessage& msg)
{
	if(g_game.getGameState() == GAMESTATE_SHUTDOWN)
	{
		getConnection()->close();
		return;
	}

	msg.skip(2);
	uint16_t version = msg.get<uint16_t>();

	msg.skip(12);
	if(version <= 760)
		disconnectClient(0x0A, "Only clients with protocol " CLIENT_VERSION_STRING " allowed!");

	if(!RSA_decrypt(msg))
	{
		getConnection()->close();
		return;
	}

	uint32_t key[4] = {msg.get<uint32_t>(), msg.get<uint32_t>(), msg.get<uint32_t>(), msg.get<uint32_t>()};
	enableXTEAEncryption();
	setXTEAKey(key);

	if(version <= 822)
		disableChecksum();

	disconnectClient(0x0A, "Only clients with protocol " CLIENT_VERSION_STRING " allowed!");
}
开发者ID:A-Syntax,项目名称:crystalserver,代码行数:30,代码来源:protocolold.cpp

示例5: while

void            Server::run()
{
  ENetEvent     event;

  std::cout << "Actual port => " << _set.getCvar("sv_port") << std::endl;
  std::cout << "Quiet => " << _set.getCvar("sv_quiet") << std::endl;
  std::cout << "Debug => " << _set.getCvar("sv_debug") << std::endl;

  while ((enet_host_service(_server, &event, 50)) >= 0)
    {
      switch (event.type)
        {
        case ENET_EVENT_TYPE_CONNECT:
          connectClient(event.peer);
          break;
        case ENET_EVENT_TYPE_RECEIVE:
          handlePackets(event);
          break;
        case ENET_EVENT_TYPE_DISCONNECT:
          disconnectClient(event.peer);
        default:
          break;
        }
      updateClients();
    }
}
开发者ID:izissise,项目名称:PFA,代码行数:26,代码来源:Server.cpp

示例6: lock

bool Client::connectToServer(const std::string &host, const int port) {
    std::unique_lock<std::mutex> lock(connectedEventReceivedMutex);
    
    remoteConnection.reset(new ZeroMQClient(incoming_event_buffer,
                                            outgoing_event_buffer,
                                            host,
                                            port,
                                            port + 1));
    if (!remoteConnection->connect()) {
        //TODO log the error somewhere.
        return false; 
    }
    
    // Send client connected event, using memory address of remoteConnection as the client ID
    putEvent(SystemEventFactory::clientConnectedToServerControl(reinterpret_cast<long>(remoteConnection.get())));
    
    // Wait for connection acknowledgement from server
    connectedEventReceived = false;
    if (!connectedEventReceivedCondition.wait_for(lock,
                                                  std::chrono::seconds(2),
                                                  [this]() { return connectedEventReceived; }))
    {
        (void)disconnectClient();
        return false;
    }
    
    // Request component codec, variable codec, experiment state, and protocol names
    putEvent(SystemEventFactory::requestComponentCodecControl());
    putEvent(SystemEventFactory::requestCodecControl());
    putEvent(SystemEventFactory::requestExperimentStateControl());
    putEvent(SystemEventFactory::requestProtocolsControl());
    
    return true;
}
开发者ID:mworks,项目名称:mworks,代码行数:34,代码来源:Client.cpp

示例7: rx

bool Server::stateRecieveField( const QString& cmd, ClientsIterator client )
{
    QRegExp rx( "field:(\\d{1,2}):([0-8]+):" );
    if( rx.indexIn(cmd) == -1 )
        return false;

    if( client->status != Client::ST_AUTHORIZED )
        return false;

    int shipSize = rx.cap(1).toInt();
    const QString& field = rx.cap(2);

    client->setField( field, shipSize );
    if( !client->field()->checkField() )
    {
        client->send( "wrongfield:" );
        qDebug() << "User" << client->login << "passed wrong field";
        client->field()->showField();
        disconnectClient( client );
        return true;
    }

    client->status = Client::ST_READY;
    return true;
}
开发者ID:andriymoroz,项目名称:SeaCraft,代码行数:25,代码来源:Server.cpp

示例8: disconnectClient

void InspectorFrontendHost::disconnectFromBackend()
{
    if (m_client) {
        m_client->disconnectFromBackend();
        disconnectClient(); // Disconnect from client.
    }
}
开发者ID:dankurka,项目名称:webkit_titanium,代码行数:7,代码来源:InspectorFrontendHost.cpp

示例9: disconnectClient

Client::~Client() {
    disconnectClient();
    
    if (incoming_listener) {
        incoming_listener->killListener();
    }
}
开发者ID:mworks,项目名称:mworks,代码行数:7,代码来源:Client.cpp

示例10: QTC_ASSERT

void QmlProfilerClientManager::connectToTcpServer()
{
    if (m_connection.isNull()) {
        QTC_ASSERT(m_qmlclientplugin.isNull(), disconnectClient());
        createConnection();
        QTC_ASSERT(m_connection, emit connectionFailed(); return);
        m_connection->connectToHost(m_tcpHost, m_tcpPort.number());
    }
开发者ID:yueying,项目名称:qt-creator,代码行数:8,代码来源:qmlprofilerclientmanager.cpp

示例11: recordSessionStatistic

// Disconnect client from server and record winner status for him and his
// opponent, if there was a game between'em
void Server::disconnectClientAndRecord(
    ClientsIterator client,
    bool winnerStatus
)
{
    if( client == clients_.end() )
        return;

    if(
        client->status == Client::ST_MAKING_STEP ||
        client->status == Client::ST_WAITING_STEP
    )
    {
        Client& winner = winnerStatus
            ? client.value()
            : client->playingWith.value();
        Client& looser = !winnerStatus
            ? client.value()
            : client->playingWith.value();

        recordSessionStatistic(
            winner.login,
            looser.login
        );

        PlayerStats stat = stats_.getStat(winner.login);
        QString winInfo("win: winRate: ");
        winInfo.append(QString::number(stat.roundsWon));
        winInfo.append(" loseRate: ");
        winInfo.append(QString::number(stat.roundsLost));

        stat = stats_.getStat(looser.login);
        QString loseInfo("lose: winRate: ");
        loseInfo.append(QString::number(stat.roundsWon));
        loseInfo.append(" loseRate: ");
        loseInfo.append(QString::number(stat.roundsLost));

        winner.send(winInfo);
        looser.send(loseInfo);
    }

    if( client->playingWith != clients_.end() )
        disconnectClient( client->playingWith );

    disconnectClient( client );
}
开发者ID:andriymoroz,项目名称:SeaCraft,代码行数:48,代码来源:Server.cpp

示例12: disconnectClient

void QmlProfilerClientManager::clearConnection()
{
    m_localSocket.clear();
    m_tcpHost.clear();
    m_tcpPort = Utils::Port();
    disconnectClient();
    stopConnectionTimer();
}
开发者ID:qtproject,项目名称:qt-creator,代码行数:8,代码来源:qmlprofilerclientmanager.cpp

示例13: disconnectClient

void ProtocolLogin::getCharacterList(const std::string& accountName, const std::string& password, uint16_t version)
{
	Account account;
	if (!IOLoginData::loginserverAuthentication(accountName, password, account)) {
		disconnectClient("Account name or password is not correct.", version);
		return;
	}

	auto output = OutputMessagePool::getOutputMessage();
	//Update premium days
	Game::updatePremium(account);

	const std::string& motd = g_config.getString(ConfigManager::MOTD);
	if (!motd.empty()) {
		//Add MOTD
		output->addByte(0x14);

		std::ostringstream ss;
		ss << g_game.getMotdNum() << "\n" << motd;
		output->addString(ss.str());
	}

	//Add session key
	output->addByte(0x28);
	output->addString(accountName + "\n" + password);

	//Add char list
	output->addByte(0x64);

	output->addByte(1); // number of worlds

	output->addByte(0); // world id
	output->addString(g_config.getString(ConfigManager::SERVER_NAME));
	output->addString(g_config.getString(ConfigManager::IP));
	output->add<uint16_t>(g_config.getNumber(ConfigManager::GAME_PORT));
	output->addByte(0);

	uint8_t size = std::min<size_t>(std::numeric_limits<uint8_t>::max(), account.characters.size());
	output->addByte(size);
	for (uint8_t i = 0; i < size; i++) {
		output->addByte(0);
		output->addString(account.characters[i]);
	}

	// Add premium days
	if (version >= 1080) {
		output->addByte((g_config.getBoolean(ConfigManager::FREE_PREMIUM)) ? 0x01 : 0x00);
		auto time = std::chrono::system_clock::now() + std::chrono::hours(account.premiumDays * 24);
		std::chrono::seconds timestamp = std::chrono::duration_cast<std::chrono::seconds>(time.time_since_epoch());
		output->add<uint32_t>(g_config.getBoolean(ConfigManager::FREE_PREMIUM) ? 0 : timestamp.count());
	} else {
		output->add<uint16_t>(g_config.getBoolean(ConfigManager::FREE_PREMIUM) ? 0xFFFF : account.premiumDays);
	}

	send(output);

	disconnect();
}
开发者ID:edumntg,项目名称:Vanaheim,代码行数:58,代码来源:protocollogin.cpp

示例14: sendExit

//--------------------------------------------------------------
void ofxMatrixNetworkServer::exit() {
    //for each client lets send them a message letting them know what port they are connected on
	for(int i = 0; i < getLastID(); i++){
		if(isClientConnected(i)){
            sendExit(i);
            disconnectClient(i);
        }
	}
    
    close();
}
开发者ID:maybites,项目名称:ofxMatrixNetworkServer,代码行数:12,代码来源:ofxMatrixNetworkServer.cpp

示例15: handleClient

static int
handleClient(int handle, void *context)
{
  int rc;
  ClientRef client = (ClientRef) context;
  rc = handleClientRequest(client);
  if (rc <= 0) {
    disconnectClient(client);
  }
  return rc;
}
开发者ID:ualerts-org,项目名称:ualerts-av-control,代码行数:11,代码来源:dispatcher.c


注:本文中的disconnectClient函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。