void NFCMasterNet_ServerModule::OnSocketEvent(const int nSockIndex, const NF_NET_EVENT eEvent, NFINet* pNet) { //std::cout << "OnSocketEvent::thread id=" << GetCurrentThreadId() << std::endl; if (eEvent & NF_NET_EVENT_EOF) { m_pLogModule->LogNormal(NFILogModule::NLL_INFO_NORMAL, NFGUID(0, nSockIndex), "NF_NET_EVENT_EOF", "Connection closed", __FUNCTION__, __LINE__); OnClientDisconnect(nSockIndex); } else if (eEvent & NF_NET_EVENT_ERROR) { m_pLogModule->LogNormal(NFILogModule::NLL_INFO_NORMAL, NFGUID(0, nSockIndex), "NF_NET_EVENT_ERROR", "Got an error on the connection", __FUNCTION__, __LINE__); OnClientDisconnect(nSockIndex); } else if (eEvent & NF_NET_EVENT_TIMEOUT) { m_pLogModule->LogNormal(NFILogModule::NLL_INFO_NORMAL, NFGUID(0, nSockIndex), "NF_NET_EVENT_TIMEOUT", "read timeout", __FUNCTION__, __LINE__); OnClientDisconnect(nSockIndex); } else if (eEvent == NF_NET_EVENT_CONNECTED) { m_pLogModule->LogNormal(NFILogModule::NLL_INFO_NORMAL, NFGUID(0, nSockIndex), "NF_NET_EVENT_CONNECTED", "connectioned success", __FUNCTION__, __LINE__); OnClientConnected(nSockIndex); } }
int NFCLoginNet_ServerModule::OnSocketClientEvent( const int nSockIndex, const NF_NET_EVENT eEvent, NFINet* pNet ) { if (eEvent & NF_NET_EVENT_EOF) { m_pLogModule->LogNormal(NFILogModule::NLL_INFO_NORMAL, NFIDENTID(0, nSockIndex), "NF_NET_EVENT_EOF", "Connection closed", __FUNCTION__, __LINE__); OnClientDisconnect(nSockIndex); } else if (eEvent & NF_NET_EVENT_ERROR) { m_pLogModule->LogNormal(NFILogModule::NLL_INFO_NORMAL, NFIDENTID(0, nSockIndex), "NF_NET_EVENT_ERROR", "Got an error on the connection", __FUNCTION__, __LINE__); OnClientDisconnect(nSockIndex); } else if (eEvent & NF_NET_EVENT_TIMEOUT) { m_pLogModule->LogNormal(NFILogModule::NLL_INFO_NORMAL, NFIDENTID(0, nSockIndex), "NF_NET_EVENT_TIMEOUT", "read timeout", __FUNCTION__, __LINE__); OnClientDisconnect(nSockIndex); } else if (eEvent == NF_NET_EVENT_CONNECTED) { m_pLogModule->LogNormal(NFILogModule::NLL_INFO_NORMAL, NFIDENTID(0, nSockIndex), "NF_NET_EVENT_CONNECTED", "connectioned success", __FUNCTION__, __LINE__); OnClientConnected(nSockIndex); } return 0; }
//General "Network" / Gamemode AMX Code void CNetwork::OnServerChangeMap() { printf("OnServerChangeMap() has been called.\n"); int idx; cell ret = 0; CBaseEntity *entity = new CBaseEntity; Precache *precache = new Precache; CBasePlayer *pPlayer = new CBasePlayer(); //Dump all the clients from the table because the map was changed.. for(size_t i=0; i<ReadInt32(SVS_MAXCLIENTS); i++) { if(pPlayer->IsClientConnected(i)) { if(pPlayer->IsClientOnTable(i)) { OnClientDisconnect(i, REASON_MAPCHANGE); } } } delete pPlayer; //amx push would go below here.. (So we can push the OnServerChangeMap data to the loaded AMX script later) if (!amx_FindPublic(&inimod_amx, "OnServerChangeMap", &idx)) { amx_Exec(&inimod_amx, &ret, idx); precache->PreloadCached(false); //Don't delete anything the users precached.. } if((long)ret == 1) { printf("ret returned %d\n", ret); } entity->OnServerChangeMap(); delete entity; delete precache; }
void CNetwork::OnClientReconnect(cell playerid) { CBasePlayer *pPlayer = new CBasePlayer(); printf("OnClientReconnect(%d) has been called\n", playerid); if(pPlayer->IsClientOnTable(playerid)) { OnClientDisconnect(playerid, REASON_DISCONNECT); //The client disconnected remove them from the table to prevent the glitching bug -1 } delete pPlayer; }
void CClientMgr::ProcessAllClient() { std::list<CClient*>::iterator itr, tempitr; for (itr = m_ClientList.begin(); itr != m_ClientList.end();) { tempitr = itr; ++itr; //从连接上来,经过若干时间,还未认证,则断开连接 if ((*tempitr)->IsEnoughXMNotAlreadyAuth(g_currenttime)) { (*tempitr)->GetCon()->Close(); } if ((*tempitr)->IsNeedRemove()) { //ClientConnectLog("服务器延时移除Client, ID:%d, 剩余Client数量:%d", (*tempitr)->GetClientID(), (int32)m_ClientList.size() - 1); assert((*tempitr)->IsInNormal()); (*tempitr)->SetInWaitRemove(); (*tempitr)->GetCon()->CheckSend(); m_WaitRemove.push_back(*tempitr); m_ClientList.erase(tempitr); continue; } if ((*tempitr)->GetCon()->IsClose()) { log_writelog("与Client的连接断开, id:%d, 剩余Client数量:%d", (*tempitr)->GetClientID(), (int32)m_ClientList.size() - 1); OnClientDisconnect(*tempitr); m_ClientList.erase(tempitr); continue; } if ((*tempitr)->IsOverTime(g_currenttime, m_OverTime)) { log_writelog("与Client的连接超时关闭, id:%d, 剩余Client数量:%d", (*tempitr)->GetClientID(), (int32)m_ClientList.size() - 1); (*tempitr)->GetCon()->Close(); OnClientDisconnect(*tempitr); m_ClientList.erase(tempitr); continue; } ProcessClientMsg(*tempitr); } }
void PlayerManager::OnSourceModLevelEnd() { /* Disconnect all bots still in game */ for (int i=1; i<=m_maxClients; i++) { if (m_Players[i].IsConnected()) { OnClientDisconnect(m_Players[i].GetEdict()); } } m_PlayerCount = 0; }
void AFCLoginNetServerModule::OnSocketClientEvent(const NetEventType eEvent, const AFGUID& xClientID, const int nServerID) { if(eEvent == DISCONNECTED) { ARK_LOG_INFO("Connection closed, id = {}", xClientID.ToString().c_str()); OnClientDisconnect(xClientID); } else if(eEvent == CONNECTED) { ARK_LOG_INFO("Connected success, id = {}", xClientID.ToString().c_str()); OnClientConnected(xClientID); } }
int NFCGameServerToWorldModule::OnSocketEvent( const int nSockIndex, const NF_NET_EVENT eEvent ) { if (eEvent == NF_NET_EVENT_CONNECTED) { m_pLogModule->LogNormal(NFILogModule::NLL_INFO_NORMAL, NFIDENTID(0, nSockIndex), "NF_NET_EVENT_CONNECTED", "Connected success", __FUNCTION__, __LINE__); OnClientConnected(nSockIndex); } else { m_pLogModule->LogNormal(NFILogModule::NLL_INFO_NORMAL, NFIDENTID(0, nSockIndex), "NF_NET_EVENT_EOF", "Connection closed or Got an error!", __FUNCTION__, __LINE__); OnClientDisconnect(nSockIndex); } return 0; }
// Disconnect our user void CServerSocket::DisconnectClient( CClientSocket* thisclient ) { ConnectedClients--; OnClientDisconnect( thisclient ); closesocket( thisclient->sock ); thisclient->isActive = false; thisclient->sock = INVALID_SOCKET; for(UINT i=0;i<ClientList.size( );i++) { CClientSocket* client = ClientList.at( i ); if( client == thisclient ) { ClientList.erase( ClientList.begin( ) + i ); break; } } DeleteClientSocket( thisclient ); }
bool CModules::OnClientDisconnect() { MODUNLOADCHK(OnClientDisconnect()); return false; }