Пример #1
0
void SessionSrv::MessageResponse(Message* message)
{
	CTaskID task_id = *(CTaskID*)message->ReadPayload(0);
	GS_INT taskType = (*(GS_INT*)message->ReadPayload(1));
	GS_DWORD taskResult = *(GS_DWORD*)message->ReadPayload(2);
	GS_DWORD taskDetailedResult = *(GS_DWORD*)message->ReadPayload(3);
#if defined(_XBOX) || defined(_XENON)
	GS_DWORD taskExtendedResult = *(GS_DWORD*)message->ReadPayload(4);
#endif

#if defined(_XBOX) || defined(_XENON)
	if (ERROR_SUCCESS == taskResult)
#elif defined(_PS3)
	if (0 == taskResult)
#endif
	{
		switch (taskType)
		{
		case EGSTaskType_SessionCreate:
		case EGSTaskType_SessionJoin:
			m_IsCreated = TRUE;
			break;
		case EGSTaskType_SessionStart:
			m_IsStarted = TRUE;
			break;
		case EGSTaskType_SessionEnd:
			m_IsStarted = FALSE;
			break;
		case EGSTaskType_SessionDelete:
		case EGSTaskType_SessionLeave:
			m_IsCreated = FALSE;
#if defined(_XBOX) || defined(_XENON)
			m_hSession = INVALID_HANDLE_VALUE;
#endif
			break;
		default:
			break;
		}
	}

	// Message to Interface
	Message* msg = Message::Create(EMessage_CallBackInterface);
	if (msg)
	{
		msg->AddPayload(taskType);

#if defined(_XBOX) || defined(_XENON)
		GS_BOOL result = (ERROR_SUCCESS == taskResult) ? TRUE : FALSE;
#elif defined(_PS3)
		GS_BOOL result = (0 == taskResult) ? TRUE : FALSE;
#else
		GS_BOOL result = TRUE;
#endif
		msg->AddPayload(result);

		msg->AddTarget(Master::G()->GetInterfaceMgr());

		Master::G()->GetMessageMgr()->Send(msg);

	}

}