void CTcpSessionManager::SendSessionData(AccepterID aID, SessionID sID, ProtocolID pID, const char * userData, unsigned int userDataLen) { WriteStreamPack ws; ws << pID; ws.AppendOriginalData(userData, userDataLen); SendOrgSessionData(aID, sID, ws.GetStream(), ws.GetStreamLen()); }
void CTcpSessionManager::SendConnectorData(ConnectorID cID, ProtocolID pID, const char * userData, unsigned int userDataLen) { WriteStreamPack ws; ws << pID; ws.AppendOriginalData(userData, userDataLen); SendOrgConnectorData(cID, ws.GetStream(), ws.GetStreamLen()); }
void CNetManager::event_OnSessionEstablished(SessionID sID) { WriteStreamPack ws; DT2OS_DirectServerAuth auth; auth.srcNode = GlobalFacade::getRef().getServerConfig().getOwnServerNode(); auth.srcIndex = GlobalFacade::getRef().getServerConfig().getOwnNodeIndex(); ws << ID_DT2OS_DirectServerAuth << auth; CTcpSessionManager::getRef().SendOrgSessionData(sID, ws.GetStream(), ws.GetStreamLen()); LOGD("send DT2OS_DirectServerAuth sID=" << sID << ", node=" << auth.srcNode << ", index=" << auth.srcIndex); }
void OnSessionHeartbeatTimer(AccepterID aID, SessionID sID) { auto iter = m_sessionHB.find(sID); if (iter == m_sessionHB.end() || time(NULL) - iter->second > HEARTBEART_INTERVAL/1000 * 2) { LOGI("remote session lost. sID=" << sID << ", timeout=" << time(NULL) - iter->second); CTcpSessionManager::getRef().KickSession(aID, sID); } WriteStreamPack pack; pack << S2C_HEARTBEAT; CTcpSessionManager::getRef().SendOrgSessionData(aID, sID, pack.GetStream(), pack.GetStreamLen()); }
void OnConnecotrHeartbeatTimer(ConnectorID cID) { auto iter = m_connectorHB.find(cID); if (iter == m_connectorHB.end() || time(NULL) - iter->second > HEARTBEART_INTERVAL/1000*2) { LOGI("server lost. cID=" << cID << ", timeout=" << time(NULL) - iter->second); CTcpSessionManager::getRef().BreakConnector(cID); } WriteStreamPack pack; pack << C2S_HEARTBEAT; CTcpSessionManager::getRef().SendOrgConnectorData(cID, pack.GetStream(), pack.GetStreamLen()); }
void OnConnected (ConnectorID cID) { LOGI("OnConnected. ConnectorID=" << cID ); WriteStreamPack ws; ws << C2S_ECHO_REQ << "client request one REQ."; CTcpSessionManager::getRef().SendOrgConnectorData(cID, ws.GetStream(), ws.GetStreamLen()); g_totalSendCount++; if (g_sendType != 0 && g_intervalMs > 0) { CTcpSessionManager::getRef().CreateTimer(g_intervalMs, std::bind(&CStressClientHandler::SendFunc, this, cID)); m_sessionStatus[cID] = true; } };
void SendFunc(ConnectorID cID) { if (g_totalSendCount - g_totalRecvCount < 10000) { WriteStreamPack ws; ws << C2S_ECHO_REQ << g_testStr; CTcpSessionManager::getRef().SendOrgConnectorData(cID, ws.GetStream(), ws.GetStreamLen()); g_totalSendCount++; } if (m_sessionStatus[cID]) { CTcpSessionManager::getRef().CreateTimer(g_intervalMs, std::bind(&CStressClientHandler::SendFunc, this, cID)); } };
void msg_ResultSequence_fun(ConnectorID cID, ProtocolID pID, ReadStreamPack & rs) { std::string msg; rs >> msg; g_totalRecvCount++; g_totalEchoCount++; if (g_sendType == 0 || g_intervalMs == 0) //echo send { WriteStreamPack ws; ws << C2S_ECHO_REQ << g_testStr; CTcpSessionManager::getRef().SendOrgConnectorData(cID, ws.GetStream(), ws.GetStreamLen()); g_totalSendCount++; } };