本文整理汇总了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!");
}
示例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;
}
示例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;
}
示例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!");
}
示例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();
}
}
示例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;
}
示例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;
}
示例8: disconnectClient
void InspectorFrontendHost::disconnectFromBackend()
{
if (m_client) {
m_client->disconnectFromBackend();
disconnectClient(); // Disconnect from client.
}
}
示例9: disconnectClient
Client::~Client() {
disconnectClient();
if (incoming_listener) {
incoming_listener->killListener();
}
}
示例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());
}
示例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 );
}
示例12: disconnectClient
void QmlProfilerClientManager::clearConnection()
{
m_localSocket.clear();
m_tcpHost.clear();
m_tcpPort = Utils::Port();
disconnectClient();
stopConnectionTimer();
}
示例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();
}
示例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();
}
示例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;
}