Exemple #1
0
	void CApp::BindSidXid(SID iSid,const XID& sXid)
	{
		if (iSid && sXid.IsValid())
		{
			AutoSpinLock(lock, m_pSidXidLock);
			m_mSidXid[iSid] = sXid;
		}
	}
Exemple #2
0
	Bool CApp::DispatchTick(const XID& sXid)
	{
		if(sXid.IsValid())
		{
			SafeObj obj(sXid);
			if (obj.IsObjValid())
				return obj->OnTick();		
		}
		return false;
	}
Exemple #3
0
	Bool CApp::DispatchMsg(const XID& sXid, CMsg* pMsg)
	{
		if(sXid.IsValid() && pMsg && pMsg->Msg > 0 && pMsg->Target.IsValid())
		{
			SafeObj obj(pMsg->Target);
			if (obj.IsObjValid())
				return obj->OnMessage(*pMsg);		
		}
		return false;
	}
Exemple #4
0
	Bool CApp::DispatchProto(const XID& sXid, SID iSid, Protocol* pProto)
	{
		if(sXid.IsValid() && pProto)
		{
			SafeObj obj(sXid);
			if (obj.IsObjValid())
				return obj->OnProtocol(iSid, pProto);
		}	
		return false;
	}
Exemple #5
0
	Bool  CApp::DeleteObj(const XID& sXid)
	{
		if (sXid.IsValid())
		{
			ObjMan* pObjMan = GetObjMan(sXid.Type);
			Assert(pObjMan);

			return pObjMan->FreeObject(sXid);
		}
		return true;
	}
Exemple #6
0
	Bool CApp::PostMsg(const XID& sXid, CMsg* pMsg)
	{
		CMsg* pRealMsg = (CMsg*)pMsg;
		if (pRealMsg && sXid.IsValid())
		{
			pRealMsg->Target = sXid;
			return PostMsg(pRealMsg);
		}
		
		g_MsgManager->FreeMsg(pRealMsg);
		return false;
	}
Exemple #7
0
	Bool CApp::PostProtocol(const XID& sXid, SID iSid, Protocol* pProto)
	{
		if (m_bRunning && iSid && pProto && 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;
	}
Exemple #8
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);
	}