Exemplo n.º 1
0
        //sender Id is assigned at the socketListener and is the message sender's sessionId
        protected void ProcessMessage(Message receivedMessage, Guid senderId, List <Guid> recipients)
        {
            switch (receivedMessage.MessageType)
            {
            case MessageType.Connect:
                mServerStateMachine.ConnectionHandler.ReceiveRequest(receivedMessage, senderId);
                break;

            case MessageType.Event:
                ServerAccount account   = mServerStateMachine.SessionManager.GetServerAccountFromSessionId(senderId);
                string        accountId = "";
                if (account != null)
                {
                    accountId = account.AccountId.ToString();
                }
                Metrics.Log(receivedMessage, accountId);
                break;

            case MessageType.Create:
                break;

            case MessageType.Update:
                mServerStateMachine.ServerObjectRepository.ReceiveRequest(receivedMessage, senderId);
                break;

            case MessageType.Room:
                mServerStateMachine.RoomManager.ReceiveRequest(receivedMessage, senderId);
                break;

            case MessageType.Friends:
                mServerStateMachine.FriendsManager.ReceiveRequest(receivedMessage, senderId);
                break;

            case MessageType.Admin:
                mServerStateMachine.AdminManager.ReceiveRequest(receivedMessage, senderId);
                break;

            case MessageType.PaymentItems:
                mServerStateMachine.PaymentItemsManager.ReceiveRequest(receivedMessage, senderId);
                break;

            case MessageType.FashionMinigame:
                mServerStateMachine.FashionMinigameServer.ReceiveRequest(receivedMessage, senderId);
                break;

            case MessageType.Account:
                mServerStateMachine.UsersManager.ReceiveRequest(receivedMessage, senderId);
                break;

            case MessageType.AssetRepository:
                mServerStateMachine.ServerAssetRepository.ReceiveRequest(receivedMessage, senderId);
                break;

            case MessageType.Heartbeat:
                //answer the heartbeat call
                ProcessHeartbeatMessage(receivedMessage, senderId);
                break;

            case MessageType.Escrow:
                mServerStateMachine.EscrowManager.ReceiveRequest(receivedMessage, senderId);
                break;

            default:
                mLogger.Error("Unable to process a message with unexpected MessageType (" + receivedMessage.MessageType + ")");
                break;
            }
            //foreach (object o in receivedMessage.Data)
            //{
            //    Console.WriteLine(o.ToString() + " : " + o.GetType().ToString());
            //}
        }