예제 #1
0
void ForServerMsgHandler::NofityClientExit(BaseSession* pSession, const NetMsgHead* pMsg,int32 nSize)
{
	const SSNofityClientExit* pPacket = static_cast<const SSNofityClientExit*>(pMsg);
	int32 nClientSessionID = pPacket->nClientSessionID;

	ClientSession* pClientSession = ClientSessionMgr::Instance()->GetSession(nClientSessionID);
	ASSERT(pClientSession);

	// 同步或保存重要数据到dp

	// 通知ls,ss
	SSNofityClientExit sMsgExit;
	sMsgExit.nClientSessionID = nClientSessionID;

	pClientSession->SendMsgToLs(&sMsgExit,sMsgExit.GetPackLength());
	if(pClientSession->Status() == ECLIENT_STATUS_IN_SCENE)
	{
		pClientSession->SendMsgToSs(&sMsgExit,sMsgExit.GetPackLength());
	}else
	{
		// 由dp去保存退出操作
		pClientSession->SendMsgToDp(&sMsgExit,sMsgExit.GetPackLength());
	}

	// 删除
	ClientSessionMgr::Instance()->RemoveSession(nClientSessionID);

}
예제 #2
0
		virtual void QueryResult(IDbRecordSet* pSet, int32 nCount)
		{
			const DbRecordSet* pRecordSet = static_cast<const DbRecordSet*>(pSet);
			D2LCharacterList sMsg;
			sMsg.nCount = 0;
			for (int32 i = 0; i < pRecordSet->Rows(); ++i)
			{
				if (i < MAX_ROLE_TYPE_COUNT)
				{
					memcpy(&sMsg.arrInfo[i], pRecordSet->GetRecordData(i), sizeof(D2LCharacterList::StCharacterInfo));
					sMsg.nCount++;
				}
				else
				{
					FLOG_ERROR(__FUNCDNAME__, __LINE__, "Role number too more!");
				}
			}
			pClientSession->SendMsgToLs(&sMsg, sMsg.GetPackLength());
		}
예제 #3
0
void ProcServerHandler::DbRoleCreate(void* pSession,const void* pData)
{

#pragma pack(push,1)
	struct StCreateResult
	{
		int64 nNewCharID;
		int32 nAccountID;
	};
#pragma pack(pop)

	ClientSession* pClientSession = static_cast<ClientSession*>(pSession);
	const DbRecordSet* pRecordSet = static_cast<const DbRecordSet*>(pData);
	const StCreateResult* pCreateResult = static_cast<const StCreateResult*>(pRecordSet->GetRecordData(0));
	int64  nNewID = pCreateResult->nNewCharID;
	int32  nAccountID = pCreateResult->nAccountID;

	D2LRoleCreateResult sMsg;
	if(nNewID == 0)
	{
		sMsg.nResult = D2LRoleCreateResult::E_FAIL_SYNC;
	}else if(nNewID == 1)
	{
		sMsg.nResult = D2LRoleCreateResult::E_FAIL_ROLE_MAX;
	}
	else if (nNewID == 2)
	{
		sMsg.nResult = D2LRoleCreateResult::E_FAIL_NAME_EXIST;
	}
	else if (nNewID == 3)
	{
		sMsg.nResult = D2LRoleCreateResult::E_FAIL_INSERT_FAIL;
	}else
	{
		sMsg.nNewCharID = nNewID;
		sMsg.nResult = D2LRoleCreateResult::E_SUCCESS;
		QueryCharacterList(pClientSession,nAccountID,0);
	}
	pClientSession->SendMsgToLs(&sMsg,sMsg.GetPackLength());

}
예제 #4
0
void ForServerMsgHandler::ReqRoadLest(BaseSession* pSession, const NetMsgHead* pMsg,int32 nSize)
{
	//---------------------------------服务组代码begin-------------------------------
	const SSReqLoadLest* pPacket = static_cast<const SSReqLoadLest*>(pMsg);
	int32 nClientSessionID = pPacket->nClientSessionID;
	ServerSession* pFepSession = static_cast<ServerSession*>(pSession);

	// 找出分配最小的(或上一次分配的,以后再优化)
	ServerInfoMgr* pServerInfoMgr = ServerInfoMgr::Instance();
	ServerSession* pLsSession = pServerInfoMgr->GetLoadLestSession(ESERVER_TYPE_LS);
	ServerSession* pDpSession = pServerInfoMgr->GetLoadLestSession(ESERVER_TYPE_DP);
	ASSERT(pLsSession && pDpSession);

	// 第一次创建ClientSesson数据
	ClientSession* pClientSession = ClientSessionMgr::Instance()->AddSession(nClientSessionID);
	ASSERT(pClientSession);
	pClientSession->SetForWs1(pFepSession,pLsSession,pDpSession);

	// 同步到ls,dp,fep
	SSSessionNofitySInfo sNofityInfo;
	sNofityInfo.nClientSessionID = nClientSessionID;
	sNofityInfo.nLsServerID = pLsSession->ServerID();
	sNofityInfo.nDpServerID = pDpSession->ServerID();
	sNofityInfo.nFepServerID = pFepSession->ServerID();

	// 通知分配给Client的ServerID
	pClientSession->SendMsgToLs(&sNofityInfo,sNofityInfo.GetPackLength());
	pClientSession->SendMsgToDp(&sNofityInfo,sNofityInfo.GetPackLength());
	pClientSession->SendMsgToFep(&sNofityInfo,sNofityInfo.GetPackLength());

	// 负载+1
	pServerInfoMgr->OnLoadAddOne(pLsSession->ServerID());
	pServerInfoMgr->OnLoadAddOne(pDpSession->ServerID());
	pServerInfoMgr->OnLoadAddOne(pFepSession->ServerID());
	//---------------------------------服务组代码end-------------------------------

}
예제 #5
0
		virtual void QueryResult(IDbRecordSet* pSet, int32 nCount)
		{
			const DbRecordSet* pRecordSet = static_cast<const DbRecordSet*>(pSet);
			if (pRecordSet->Rows() > 0)
			{
				if (int64 nAccountId = *static_cast<int64*>(pRecordSet->GetRecordData(0)))
				{
					// 返回登录结果成功 
					D2LAccountLogin sMsg;
					sMsg.nAccountId = nAccountId;
					sMsg.nResult = D2LAccountLogin::E_RESULT_SUCCESS;
					pClientSession->SendMsgToLs(&sMsg, sMsg.GetPackLength());
					// 继续查询角色
					QueryCharacterList(pClientSession, nAccountId, 0);
					return;
				}
			}

			// 将查询到的记录反回到login
			D2LAccountLogin sMsg;
			sMsg.nAccountId = 0;
			sMsg.nResult = D2LAccountLogin::E_RESULT_FAIL;
			pClientSession->SendMsg(&sMsg, sMsg.GetPackLength());
		}