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


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

本文整理汇总了C++中TcpSessionPtr::getUserParam方法的典型用法代码示例。如果您正苦于以下问题:C++ TcpSessionPtr::getUserParam方法的具体用法?C++ TcpSessionPtr::getUserParam怎么用?C++ TcpSessionPtr::getUserParam使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TcpSessionPtr的用法示例。


在下文中一共展示了TcpSessionPtr::getUserParam方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: event_onSessionDisconnect

void NetManager::event_onSessionDisconnect(TcpSessionPtr session)
{
	LOGT("NetManager::event_onSessionDisconnect. SessionID=" << session->getSessionID() << ", remoteIP=" << session->getRemoteIP() << ", remotePort=" << session->getRemotePort());

	if (isConnectID(session->getSessionID()))
	{
	}
	else
	{
		if (session->getUserParam() == SS_LOGINED)
		{
			auto info = UserManager::getRef().getInnerUserInfoBySID(session->getSessionID());
			if (info)
			{
				UserManager::getRef().userLogout(info);
				info->sID = InvalidSeesionID;
			}
		}

	}

	if (UserManager::getRef().getAllOnlineUserCount() == 0 && _onSafeClosed)
	{
		SessionManager::getRef().post(_onSafeClosed);
		_onSafeClosed = nullptr;
	}
}
开发者ID:heber,项目名称:breeze,代码行数:27,代码来源:netManager.cpp

示例2: msg_onAttachLogicReq

void NetMgr::msg_onAttachLogicReq(TcpSessionPtr session, ReadStream & rs)
{
    if (std::get<TupleParamNumber>(session->getUserParam(UPARAM_SESSION_STATUS)) != SSTATUS_UNKNOW)
    {
        return;
    }
    
    AttachLogicAck ack;
    ack.retCode = EC_SUCCESS;
    AttachLogicReq req;
    rs >> req;
    LOGD("enter msg_loginReq token=" << req.token << ", uID=" << req.uID);
    do 
    {
        auto info = getUserInfo(req.uID);
        if (!info)
        {
            ack.retCode = EC_TARGET_NOT_EXIST;
            break;
        }
        if (info->token.token != req.token)
        {
            ack.retCode = EC_PERMISSION_DENIED;
            break;
        }
        if (info->token.expire < time(NULL))
        {
            ack.retCode = EC_REQUEST_EXPIRE;
            break;
        }

        if (info->sID != InvalidSessionID)
        {
            event_onLogout(info);
            SessionManager::getRef().kickSession(info->sID);
            _mapSession.erase(info->sID);
        }

        info->sID = session->getSessionID();
        session->setUserParam(UPARAM_USER_ID, info->base.uID);
        session->setUserParam(UPARAM_SESSION_STATUS, SSTATUS_LOGINED);
        session->setUserParam(UPARAM_LAST_ACTIVE_TIME, time(NULL));
        session->setUserParam(UPARAM_LOGIN_TIME, time(NULL));
        _mapSession.insert(std::make_pair(session->getSessionID(), info));

        sendMessage(session, ack);
        session->setUserParam(UPARAM_LAST_ACTIVE_TIME, time(NULL));

        event_onLogin(info);
        
        return;
    } while (0);
    
    sendMessage(session, ack);
}
开发者ID:roger912,项目名称:breeze,代码行数:55,代码来源:netMgr.cpp

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


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