当前位置: 首页>>代码示例>>C++>>正文


C++ TcpSessionPtr::doSend方法代码示例

本文整理汇总了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());
}
开发者ID:heber,项目名称:breeze,代码行数:54,代码来源:netManager.cpp

示例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());
            }
        }
    };
开发者ID:jimmy486,项目名称:zsummerX,代码行数:19,代码来源:FrameStressMain.cpp

示例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()));
        }
    };
开发者ID:jimmy486,项目名称:zsummerX,代码行数:45,代码来源:FrameStressMain.cpp

示例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());
	}
}
开发者ID:heber,项目名称:breeze,代码行数:18,代码来源:netManager.cpp


注:本文中的TcpSessionPtr::doSend方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。