本文整理汇总了C++中TcpSessionPtr::doSend方法的典型用法代码示例。如果您正苦于以下问题:C++ TcpSessionPtr::doSend方法的具体用法?C++ TcpSessionPtr::doSend怎么用?C++ TcpSessionPtr::doSend使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TcpSessionPtr
的用法示例。
在下文中一共展示了TcpSessionPtr::doSend方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: msg_onLinkServerReq
void NetManager::msg_onLinkServerReq(TcpSessionPtr session, ProtoID pID, ReadStream & rs)
{
LinkServerReq req;
rs >> req;
LOGD("enter msg_loginReq token=" << req.token << ", uID=" << req.uID);
LinkServerAck ack;
ack.retCode = EC_SUCCESS;
auto inner = UserManager::getRef().getInnerUserInfo(req.uID);
if (inner)
{
if (inner->token.token == req.token)
{
if (inner->token.tokenExpire > time(NULL))
{
ack.retCode = EC_SUCCESS;
if (inner->sID != InvalidSeesionID)
{
UserManager::getRef().userLogout(inner);
}
inner->loginTime = time(NULL);
inner->sID = session->getSessionID();
session->setUserParam(inner->userInfo.uID);
session->setUserLParam(SS_LOGINED);
session->setUserRParam(time(NULL));
WriteStream ws(ID_LinkServerAck);
ws << ack;
session->doSend(ws.getStream(), ws.getStreamLen());
UserManager::getRef().userLogin(inner);
return;
}
else
{
ack.retCode = EC_TOKEN_EXPIRE;
}
}
else
{
ack.retCode = EC_INVALIDE_USER;
}
}
else
{
ack.retCode = EC_INVALIDE_USER;
}
WriteStream ws(ID_LinkServerAck);
ws << ack;
session->doSend(ws.getStream(), ws.getStreamLen());
}
示例2: msg_ResultSequence_fun
void msg_ResultSequence_fun(TcpSessionPtr session, ReadStream & rs)
{
if (g_hightBenchmark)
{
session->doSend(rs.getStream(), rs.getStreamLen());
}
else
{
EchoPack pack;
rs >> pack;
if (g_sendType == 0 || g_intervalMs == 0) //echo send
{
WriteStream ws(ID_EchoPack);
ws << pack;
session->doSend(ws.getStream(), ws.getStreamLen());
}
}
};
示例3: SendFunc
void SendFunc(TcpSessionPtr session, bool openTimer)
{
if (SessionManager::getRef()._totalSendMessages - SessionManager::getRef()._totalRecvMessages < 10000)
{
WriteStream ws(ID_EchoPack);
EchoPack pack;
TestIntegerData idata;
idata._char = 'a';
idata._uchar = 100;
idata._short = 200;
idata._ushort = 300;
idata._int = 400;
idata._uint = 500;
idata._i64 = 600;
idata._ui64 = 700;
idata._ui128 = 255;
TestFloatData fdata;
fdata._float = (float)123123.111111;
fdata._double = 12312312.88888;
TestStringData sdata;
sdata._string = "abcdefg";
pack._iarray.push_back(idata);
pack._iarray.push_back(idata);
pack._farray.push_back(fdata);
pack._farray.push_back(fdata);
pack._sarray.push_back(sdata);
pack._sarray.push_back(sdata);
pack._imap.insert(std::make_pair("123", idata));
pack._imap.insert(std::make_pair("223", idata));
pack._fmap.insert(std::make_pair("323", fdata));
pack._fmap.insert(std::make_pair("423", fdata));
pack._smap.insert(std::make_pair("523", sdata));
pack._smap.insert(std::make_pair("623", sdata));
ws << pack;
session->doSend(ws.getStream(), ws.getStreamLen());
}
if (openTimer)
{
SessionManager::getRef().createTimer(g_intervalMs, std::bind(&CStressClientHandler::SendFunc, this, session, !session->isInvalidSession()));
}
};
示例4: 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());
}
}