本文整理汇总了C++中TcpSessionPtr::getUserLParam方法的典型用法代码示例。如果您正苦于以下问题:C++ TcpSessionPtr::getUserLParam方法的具体用法?C++ TcpSessionPtr::getUserLParam怎么用?C++ TcpSessionPtr::getUserLParam使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TcpSessionPtr
的用法示例。
在下文中一共展示了TcpSessionPtr::getUserLParam方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnSessionPulse
void OnSessionPulse(TcpSessionPtr session, unsigned int pulseInterval)
{
if (time(NULL) - session->getUserLParam() > pulseInterval/1000 * 3)
{
LOGI("remote session timeout. sID=" << session->getSessionID() << ", timeout=" << time(NULL) - session->getUserLParam());
SessionManager::getRef().kickSession(session->getSessionID());
return;
}
WriteStream pack(ID_Pulse);
SessionManager::getRef().sendSessionData(session->getSessionID(), pack.getStream(), pack.getStreamLen());
}
示例2: on_preMessageProcess
bool NetManager::on_preMessageProcess(TcpSessionPtr session, const char * blockBegin, zsummer::proto4z::Integer blockSize)
{
ReadStream rs(blockBegin, blockSize);
ProtoID pID = rs.getProtoID();
if (pID >= 200)
{
if (session->getUserLParam() != SS_LOGINED)
{
LOGW("on_preMessageProcess check authorization failed. protoID=" << pID << ", session authorization status=" << session->getUserParam());
return false;
}
}
return true;
}
示例3: event_onSessionPulse
void NetManager::event_onSessionPulse(TcpSessionPtr session, unsigned int pulseInterval)
{
if (isSessionID(session->getSessionID()))
{
if (session->getUserLParam() == SS_LOGINED || time(NULL) - session->getUserRParam() > pulseInterval * 2)
{
session->close();
return;
}
WriteStream ws(ID_Heartbeat);
Heartbeat hb;
hb.timeStamp = (ui32)time(NULL);
hb.timeTick = getNowTick();
ws << hb;
session->doSend(ws.getStream(), ws.getStreamLen());
}
}