Exemplo n.º 1
0
	Bool CApp::PostProtocol(SID iSid, Protocol* pProto)
	{
		if (m_bRunning && iSid && pProto)
		{
			XID sXid = GetXidBySid(iSid);
			if (sXid.IsValid())
			{
				Int32 iCount = GetThreadNum();
				Assert(iCount > 0);
				Int32 iIdx = sXid.Id % iCount;

				CApp_ProtoTask* pTask = new CApp_ProtoTask(sXid, iSid, pProto);
				CScope::ObjPtr scope(pTask);
				return PostAppTask(pTask, iIdx);
			}			
		}

		g_ProtocolManager->ReleaseProto(pProto);
		return true;
	}
Exemplo n.º 2
0
	Bool HsGame::OnSessionClose(SID iSid, const AString& sAddr)
	{
		if (m_mSidAddr.Find(iSid))
		{
			//注: 此处有可能在未绑定对象SID之前调用造成消息漏发
			//因: 协议通过线程池处理, 有可能在绑定协议投递而未处理时引发此处调用
			XID sXid = GetXidBySid(iSid);
			if (sXid.IsValid())
			{
				HawkMsg* pMsg = P_MsgManager->GetMsg(HSM_DISCONNECT);
				if (pMsg)
				{
					pMsg->Target = sXid;
					pMsg->Params.Push<SID>(iSid);
					PostMsg(pMsg);
				}
			}
		}

		return HawkAppFrame::OnSessionClose(iSid, sAddr);
	}
Exemplo n.º 3
0
	Bool HsGame::PostProtocol(SID iSid, Protocol* pProto)
	{
		XID sXid;
		ProtoType iType = pProto->GetType();
		if (iType == ProtocolId::LOGIN_GAME)
		{
			UString sName = ((LoginGame*)pProto)->m_sName;

			HawkStringUtil::Trim<UString>(sName);
			UInt32 iPlayerId = HawkStringUtil::HashString<UString>(sName);

			SafeObj user_obj(XID(HSO_PLAYER, iPlayerId));
			if(!user_obj.IsObjValid())
				CreateObj(XID(HSO_PLAYER, iPlayerId));

			sXid = XID(HSO_PLAYER, iPlayerId);
		}
		else
		{
			sXid = GetXidBySid(iSid);
		}

		return HawkAppFrame::PostProtocol(sXid, iSid, pProto);
	}