Ejemplo n.º 1
0
        private void OnMessageReceived(MessageBase msg)
        {
            Type type = msg.GetType();

            if (type == typeof(ValidationRequest))
            {
                ValidationRequestHandler(msg as ValidationRequest);
            }
            else if (type == typeof(SessionRequest))
            {
                SessionRequestHandler(msg as SessionRequest);
            }
            else if (type == typeof(SessionResponse))
            {
                SessionResponseHandler(msg as SessionResponse);
            }
            else if (type == typeof(EndSessionRequest))
            {
                EndSessionRequestHandler(msg as EndSessionRequest);
            }
            else if (type == typeof(DisconnectRequest))
            {
                DisconnectRequestHandler(msg as DisconnectRequest);
            }
            else if (OtherSideReceiver != null)
            {
                OtherSideReceiver.SendMessage(msg);
            }
        }
Ejemplo n.º 2
0
        private void DisconnectRequestHandler(DisconnectRequest request)
        {
            if (OtherSideReceiver != null)
            {
                OtherSideReceiver.SendMessage(new DisconnectRequest());
                OtherSideReceiver.Status = StatusEnum.Validated;
            }

            Disconnect();
        }
Ejemplo n.º 3
0
        private void EndSessionRequestHandler(EndSessionRequest request)
        {
            if (OtherSideReceiver != null)
            {
                OtherSideReceiver.SendMessage(new EndSessionRequest());
                OtherSideReceiver.Status            = StatusEnum.Validated;
                OtherSideReceiver.OtherSideReceiver = null;

                this.OtherSideReceiver = null;
                this.Status            = StatusEnum.Validated;
                this.SendMessage(new EndSessionResponse(request));
            }
        }
        public void AcceptPlayRequestHandler(AcceptPlayRequest msg)
        {
            OtherSideReceiver.SendMessage(msg);
            if (msg.IsAlready)
            {
                this.InGameProperties.Status = StatusInGame.Ready;

                if (OtherSideReceiver.InGameProperties.Status == StatusInGame.Ready)
                {
                    SetupDataAndSendToClients();
                }
            }
        }
        private void EndSessionRequestHandler(EndSessionRequest request)
        {
            if (OtherSideReceiver != null)
            {
                OtherSideReceiver.SendMessage(new EndSessionRequest());
                ResetPropertiesClientInProcess(OtherSideReceiver);
                OtherSideReceiver.Status = StatusEnum.InProcess;
            }
            ResetPropertiesClient(this);
            this.SendMessage(new EndSessionResponse(request));

            UpdateTablesInProcessRequest processRequest = new UpdateTablesInProcessRequest();

            processRequest.ClientsInProcess = GetListTableInProcess(Server.Receivers);
            foreach (Receiver re in this.Server.Receivers)
            {
                if (re.Status == StatusEnum.Validated)
                {
                    re.SendMessage(processRequest);
                }
            }
        }
        private void OnMessageReceived(MessageBase msg)
        {
            Type type = msg.GetType();

            if (type == typeof(ValidationRequest))
            {
                ValidationRequestHandler(msg as ValidationRequest);
            }
            else if (type == typeof(SessionRequest))
            {
                SessionRequestHandler(msg as SessionRequest);
            }
            else if (type == typeof(SessionResponse))
            {
                SessionResponseHandler(msg as SessionResponse);
            }
            else if (type == typeof(EndSessionRequest))
            {
                EndSessionRequestHandler(msg as EndSessionRequest);
            }
            else if (type == typeof(DisconnectRequest))
            {
                DisconnectRequestHandler(msg as DisconnectRequest);
            }
            else if (type == typeof(CreateTableRequest))
            {
                CreateTableHandler(msg as CreateTableRequest);
            }
            else if (type == typeof(TablesInProcessRequest))
            {
                ClientsInProcessRequestHandler(msg as TablesInProcessRequest);
            }
            else if (type == typeof(AcceptPlayRequest))
            {
                AcceptPlayRequestHandler(msg as AcceptPlayRequest);
            }
            else if (type == typeof(JoinPublicParkRequest))
            {
                JoinPublicParkRequestHandler(msg as JoinPublicParkRequest);
            }
            else if (type == typeof(UpdateLocationPlayerRequest))
            {
                UpdateLocationPlayerRequestHandler(msg as UpdateLocationPlayerRequest);
            }
            else if (type == typeof(ChangeLocationRequest))
            {
                ChangeLocationRequestHandler(msg as ChangeLocationRequest);
            }
            else if (type == typeof(SendMessagePublicPark))
            {
                SendMessagePublicParkHandler(msg as SendMessagePublicPark);
            }
            else if (type == typeof(LeavePublicParkRequest))
            {
                LeavePublicParkRequestHandler(msg as LeavePublicParkRequest);
            }
            else if (OtherSideReceiver != null)
            {
                if (type == typeof(GameRequest))
                {
                    GameRequestHandler(msg as GameRequest);
                    return;
                }
                else if (type == typeof(UpdateScoreRequest))
                {
                    UpdateScoreRequestHandler(msg as UpdateScoreRequest);
                }

                OtherSideReceiver.SendMessage(msg);
            }
        }