Ejemplo n.º 1
0
        private static UnknownMessage BuildUnknownMessage(JToken messageToken)
        {
            var message = new UnknownMessage();

            AttachGeneralProperties(message, messageToken);
            return(message);
        }
Ejemplo n.º 2
0
            public void Calls_fallback_when_handler_not_found()
            {
                var actor = new TestActor {Prototype = ActorPrototype.Define(typeof(TestActor))};

                var unknownMessage = new UnknownMessage();
                object bouncedMessage = null;

                Assert.DoesNotThrow(() => actor.Dispatch(unknownMessage, message => bouncedMessage = message));
                Assert.That(bouncedMessage, Is.SameAs(unknownMessage));
            }
Ejemplo n.º 3
0
        public async Task UnhandledMessageException()
        {
            var message = new UnknownMessage();
            await _session.Handle(message);

            var response = AssertAndGetSingle <ExceptionResponse>();

            Assert.IsAssignableFrom <Exception>(response.Exception);
            Assert.AreEqual(message.Id, response.ResponseTo);
        }
        public void Accepts_returns_false_if_sut_does_not_handle_message()
        {
            var            message  = new UnknownMessage();
            var            envelope = new Envelope(message);
            MessageHandler sut      = Mock.Of <MessageHandler>();

            bool actual = sut.Accepts(envelope);

            actual.Should().BeFalse();
        }
Ejemplo n.º 5
0
        public void GetActionForUnknownMessage_ThrowsMissingMessageException_Test()
        {
            // Arrange
            var inventory      = new Inventory();
            var unknownMessage = new UnknownMessage();

            // Act & Assert
            Assert.Throws <MissingMessageException>(
                () => inventory.GetActionFromMessage(unknownMessage, null));
        }
Ejemplo n.º 6
0
 public void ProcessUnknownMessage(UnknownMessage m)
 {
     if (_Client == null)
     {
         return;
     }
     if (_UnknownMessageDelegate != null)
     {
         _UnknownMessageDelegate(m.MessageText);
     }
 }
Ejemplo n.º 7
0
        public void UnhandledMessageException()
        {
            var message = new UnknownMessage();

            _session.Handle(message);

            var response = AssertAndGetSingle <ExceptionResponse>();

            Assert.IsType <RuntimeBinderException>(response.Exception);
            Assert.Equal(message.Id, response.ResponseTo);
        }
Ejemplo n.º 8
0
        public void ConvertToBaseMessage_UnknownMessage_TextMessageCreated()
        {
            var message = new UnknownMessage();

            var result = message.ConvertToBaseMessage();

            Assert.Multiple(() =>
            {
                var textMessage = (Messaging.Messages.TextMessage)result;
                Assert.That(textMessage.Body, Is.Empty);
            });
        }
Ejemplo n.º 9
0
            public void Calls_fallback_when_handler_not_found()
            {
                var actor = new TestActor {
                    Prototype = ActorPrototype.Define(typeof(TestActor))
                };

                var    unknownMessage = new UnknownMessage();
                object bouncedMessage = null;

                Assert.DoesNotThrow(() => actor.Dispatch(unknownMessage, message => bouncedMessage = message));
                Assert.That(bouncedMessage, Is.SameAs(unknownMessage));
            }
Ejemplo n.º 10
0
        public void Calls_fallback_when_handler_not_found()
        {
            var dispatcher = new Dispatcher(typeof(TestActor));

            var    unknownMessage = new UnknownMessage();
            object bouncedMessage = null;

            Assert.DoesNotThrowAsync(async() => await dispatcher.DispatchResultAsync(target, unknownMessage, message =>
            {
                bouncedMessage = message;
                return(Task.FromResult((object)42));
            }));

            Assert.That(bouncedMessage, Is.SameAs(unknownMessage));
        }
        private void should_return_unknown_message_type(MessageInterpreter interpreter)
        {
            // given
            string json = @"{ 'type': 'something_else' }";

            // when
            var result = interpreter.InterpretMessage(json);

            // then
            var expected = new UnknownMessage
            {
                RawData = json
            };

            result.ShouldLookLike(expected);
        }
Ejemplo n.º 12
0
        /* ============================================================================== Serialization */
        private IDistributedMessage DeserializeMessage(Stream data)
        {
            var bf = new BinaryFormatter();
            IDistributedMessage message;

            try
            {
                message = (IDistributedMessage)bf.Deserialize(data);
            }
            catch (SerializationException e) //logged
            {
                SnLog.WriteException(e, EventMessage.Errors.DeserializationError, EventId.Messaging);
                message = new UnknownMessage {
                    MessageData = data
                };
                // don't rethrow because caller handles
            }
            return(message);
        }
Ejemplo n.º 13
0
    public static Message DeserializeMessage(string messageJsonString)
    {
        Message message = null;

        try
        {
            message = DeserializeObject <Message>(messageJsonString);

            if (DeserializationDictionary.ContainsKey(message.Type))
            {
                message = DeserializationDictionary[message.Type].Invoke(messageJsonString);
            }
            else
            {
                message = UnknownMessage.Create(messageJsonString);
            }
        }
        catch (Exception exception)
        {
            message = InvalidMessage.Create(messageJsonString, exception);
        }

        return(message);
    }
Ejemplo n.º 14
0
        private static void Client_HostMessageReceived(object sender, Peer.MessageReceivedEventArgs e)
        {
            if (Handlers.ContainsKey(e.Message.Code))
            {
                Handlers[e.Message.Code](e.Message);
            }
            else if (e.Message as UnknownMessage != null)
            {
                UnknownMessage u = e.Message as UnknownMessage;

                byte[] codeBytes = BitConverter.GetBytes((UInt16)e.Message.Code);
                if (BitConverter.IsLittleEndian)
                {
                    Array.Reverse(codeBytes);
                }
                string codeLetter = Encoding.ASCII.GetString(codeBytes);

                WriteLine("Message " + e.Message.Code.ToString() + "(" + codeLetter + ") size " + u.DataBuffer.Length.ToString());
                if (u.DataBuffer.Length > 0)
                {
                    Write("Payload ");

                    foreach (byte b in u.DataBuffer)
                    {
                        Write(b.ToString() + " ");
                    }
                    WriteEmptyLine();
                }
            }
            else
            {
                WriteLine("Unknown Message " + e.Message.Code.ToString());
            }

            WriteEmptyLine();
        }
Ejemplo n.º 15
0
        private static void ProcessEvent(WebSocketMessage msg)
        {
            if (msg is ClientLoginResponse)
            {
                ClientLoginResponse loginResp = (ClientLoginResponse)msg;

                if (loginResp.JsonWebToken != null)
                {
                    JWTToken = loginResp.JsonWebToken;
                    UUID     = loginResp.UUID;
                    UserId   = loginResp.UserId;
                }

                ProcessJsonMessage <ClientLoginResponse>(loginResp);
            }
            else if (msg is ClientReject)
            {
                ProcessJsonMessage <ClientReject>((ClientReject)msg);
            }
            else if (msg is SubscriptionResponse)
            {
                ProcessJsonMessage <SubscriptionResponse>((SubscriptionResponse)msg);
            }
            else if (msg is AccountRecord)
            {
                ProcessJsonMessage <AccountRecord>((AccountRecord)msg);
            }
            else if (msg is DailySettlementPrice)
            {
                ProcessJsonMessage <DailySettlementPrice>((DailySettlementPrice)msg);
            }
            else if (msg is FirmRecord)
            {
                ProcessJsonMessage <FirmRecord>((FirmRecord)msg);
            }
            else if (msg is OfficialFixingPrice)
            {
                ProcessJsonMessage <OfficialFixingPrice>((OfficialFixingPrice)msg);
            }
            else if (msg is RefereceRateMsg)
            {
                ProcessJsonMessage <RefereceRateMsg>((RefereceRateMsg)msg);
            }
            else if (msg is SecurityMasterRecord)
            {
                ProcessJsonMessage <SecurityMasterRecord>((SecurityMasterRecord)msg);
            }
            else if (msg is UserRecord)
            {
                ProcessJsonMessage <UserRecord>((UserRecord)msg);
            }
            else if (msg is LastSale)
            {
                ProcessJsonMessage <LastSale>((LastSale)msg);
            }
            else if (msg is Quote)
            {
                ProcessJsonMessage <Quote>((Quote)msg);
            }
            else if (msg is CreditRecordUpdate)
            {
                ProcessJsonMessage <CreditRecordUpdate>((CreditRecordUpdate)msg);
            }
            else if (msg is DepthOfBook)
            {
                ProcessJsonMessage <DepthOfBook>((DepthOfBook)msg);
            }
            else if (msg is LegacyOrderAck)
            {
                ProcessJsonMessage <LegacyOrderAck>((LegacyOrderAck)msg);
            }
            else if (msg is LegacyOrderCancelRejAck)
            {
                ProcessJsonMessage <LegacyOrderCancelRejAck>((LegacyOrderCancelRejAck)msg);
            }
            else if (msg is ClientLogoutResponse)
            {
                ClientLogoutResponse logoutResp = (ClientLogoutResponse)msg;

                JWTToken = null;
                UserId   = null;
                UUID     = null;

                ProcessJsonMessage <ClientLogoutResponse>((ClientLogoutResponse)msg);
            }
            else if (msg is ClientHeartbeat)
            {
                ClientHeartbeat heartBeatReq = (ClientHeartbeat)msg;
                ProcessJsonMessage <ClientHeartbeat>((ClientHeartbeat)msg);
                ProcessHeartbeat(heartBeatReq.SeqNum);
            }
            else if (msg is UnknownMessage)
            {
                UnknownMessage unknownMsg = (UnknownMessage)msg;

                DoLog(string.Format("<<unknown {0}", unknownMsg.Resp));
            }
            else if (msg is ErrorMessage)
            {
                ErrorMessage errorMsg = (ErrorMessage)msg;

                DoLog(string.Format("<<unknown {0}", errorMsg.Error));
            }
            else
            {
                DoLog(string.Format("<<Unknown message type {0}", msg.ToString()));
            }

            Console.WriteLine();
        }
Ejemplo n.º 16
0
        public void AddMessageToProcess(ServerPlayer sp, byte [] b)
        {
            if (b.Length < 1)
            {
                PhazeXLog.LogError
                (
                    new Exception("Attempted to process 0 byte message!")
                    , GameLibraryVersion.ProgramIdentifier
                    , 0
                );
            }
            byte start = b[0];

            try
            {
                Message msg = null;
                switch (start)
                {
                case (byte)pxMessages.Heartbeat:
                    msg = new HeartBeatMessage(b);
                    break;

                case (byte)pxMessages.SystemMessage:
                    msg = new SystemMessage(b);
                    break;

                case (byte)pxMessages.Chat:
                    msg = new ChatMessage(b, this.getIDs());
                    break;

                case (byte)pxMessages.Ready:
                    msg = new ReadyMessage(b, this.getIDs());
                    break;

                case (byte)pxMessages.ChangeName:
                    msg = new ChangeNameMessage(b, this.getIDs());
                    break;

                case (byte)pxMessages.PlayOnGroup:
                    msg = new PlayOnGroupMessage(b, this.rules);
                    break;

                case (byte)pxMessages.Meld:
                    msg = new MeldMessage(b, this.rules);
                    break;

                case (byte)pxMessages.GetTopDiscard:
                    msg = new GetTopDiscardMessage(b);
                    break;

                case (byte)pxMessages.GetTopDeckCard:
                    msg = new GetTopDeckCardMessage(b);
                    break;

                case (byte)pxMessages.DiscardSkip:
                    msg = new DiscardSkipMessage(b, this.getIDs(), this.rules);
                    break;

                case (byte)pxMessages.Discard:
                    msg = new DiscardMessage(b, this.rules);
                    break;

                case (byte)pxMessages.RequestHand:
                    msg = new RequestHandMessage(b);
                    break;

                case (byte)pxMessages.RequestTable:
                    msg = new RequestTableMessage(b);
                    break;

                default:
                    msg = new UnknownMessage(b);
                    break;
                }
                lock (this)
                {
                    _messagesToProcess.Add(new PlayerMessage(sp, msg));
                }
            }
            catch (BadMessageException bme)
            {
                PhazeXLog.LogError
                (
                    bme
                    , GameLibraryVersion.ProgramIdentifier
                    , 109
                );

                string info = "";
                foreach (byte tmp in b)
                {
                    info += ((int)tmp).ToString() + " ";
                }
                PhazeXLog.LogInformation(info, pid);
            }
        }
Ejemplo n.º 17
0
        public virtual async void ReadResponses(object param)
        {
            while (true)
            {
                try
                {
                    string resp = "";
                    WebSocketReceiveResult webSocketResp;
                    if (SubscriptionWebSocket.State == WebSocketState.Open)
                    {
                        do
                        {
                            ArraySegment <byte> bytesReceived = new ArraySegment <byte>(new byte[1000]);
                            webSocketResp = await SubscriptionWebSocket.ReceiveAsync(bytesReceived, CancellationToken.None);

                            resp += Encoding.ASCII.GetString(bytesReceived.Array, 0, webSocketResp.Count);
                        }while (!webSocketResp.EndOfMessage);

                        if (resp != "")
                        {
                            WebSocketMessage wsResp = JsonConvert.DeserializeObject <WebSocketMessage>(resp);

                            if (wsResp.Msg == "ClientLoginResponse")
                            {
                                ClientLoginResponse loginReponse = JsonConvert.DeserializeObject <ClientLoginResponse>(resp);
                                OnEvent(loginReponse);
                            }
                            else if (wsResp.Msg == "ClientReject")
                            {
                                ClientReject loginRejected = JsonConvert.DeserializeObject <ClientReject>(resp);
                                OnEvent(loginRejected);
                            }
                            else if (wsResp.Msg == "ClientLogoutResponse")
                            {
                                ClientLogoutResponse logoutReponse = JsonConvert.DeserializeObject <ClientLogoutResponse>(resp);
                                OnEvent(logoutReponse);
                            }
                            else if (wsResp.Msg == "SubscriptionResponse")
                            {
                                SubscriptionResponse subscrResponse = JsonConvert.DeserializeObject <SubscriptionResponse>(resp);
                                OnEvent(subscrResponse);
                            }
                            else if (wsResp.Msg == "ClientHeartbeatRequest")
                            {
                                OnEvent(JsonConvert.DeserializeObject <ClientHeartbeat>(resp));
                            }
                            else if (wsResp.Msg == "AccountRecord")
                            {
                                OnEvent(JsonConvert.DeserializeObject <AccountRecord>(resp));
                            }
                            else if (wsResp.Msg == "CreditRecordUpdate")
                            {
                                OnEvent(JsonConvert.DeserializeObject <CreditRecordUpdate>(resp));
                            }
                            else if (wsResp.Msg == "DailySettlementPrice")
                            {
                                OnEvent(JsonConvert.DeserializeObject <DailySettlementPrice>(resp));
                            }
                            else if (wsResp.Msg == "FirmRecord")
                            {
                                OnEvent(JsonConvert.DeserializeObject <FirmRecord>(resp));
                            }
                            else if (wsResp.Msg == "OfficialFixingPrice")
                            {
                                OnEvent(JsonConvert.DeserializeObject <OfficialFixingPrice>(resp));
                            }
                            else if (wsResp.Msg == "RefereceRateMsg")
                            {
                                OnEvent(JsonConvert.DeserializeObject <RefereceRateMsg>(resp));
                            }
                            else if (wsResp.Msg == "SecurityMasterRecord")
                            {
                                OnEvent(JsonConvert.DeserializeObject <SecurityMasterRecord>(resp));
                            }
                            else if (wsResp.Msg == "UserRecord")
                            {
                                OnEvent(JsonConvert.DeserializeObject <UserRecord>(resp));
                            }
                            else if (wsResp.Msg == "CreditRecordUpdate")
                            {
                                OnEvent(JsonConvert.DeserializeObject <CreditRecordUpdate>(resp));
                            }
                            else if (wsResp.Msg == "LastSale")
                            {
                                OnEvent(JsonConvert.DeserializeObject <LastSale>(resp));
                            }
                            else if (wsResp.Msg == "Quote")
                            {
                                OnEvent(JsonConvert.DeserializeObject <Quote>(resp));
                            }
                            else if (wsResp.Msg == "DepthOfBook")
                            {
                                OnEvent(JsonConvert.DeserializeObject <DepthOfBook>(resp));
                            }
                            else if (wsResp.Msg == "LegacyOrderAck")
                            {
                                OnEvent(JsonConvert.DeserializeObject <LegacyOrderAck>(resp));
                            }
                            else if (wsResp.Msg == "LegacyOrderCancelRejAck")
                            {
                                OnEvent(JsonConvert.DeserializeObject <LegacyOrderCancelRejAck>(resp));
                            }
                            else
                            {
                                UnknownMessage unknownMsg = new UnknownMessage()
                                {
                                    Msg    = "UnknownMsg",
                                    Resp   = resp,
                                    Reason = string.Format("Unknown message: {0}", resp)
                                };
                                OnEvent(unknownMsg);
                            }
                        }
                    }
                    else
                    {
                        Thread.Sleep(1000);
                    }
                }
                catch (Exception ex)
                {
                    ErrorMessage errorMsg = new ErrorMessage()
                    {
                        Msg = "ErrorMsg", Error = ex.Message
                    };
                    OnEvent(errorMsg);
                }
            }
        }
Ejemplo n.º 18
0
 private void handleMessage(Message m, ServerPlayer p)
 {
     lock (this)
     {
         try
         {
             if (m == null)
             {
                 return;
             }
             if (m.GetType().Equals(typeof(HeartBeatMessage)))
             {
                 handleHeartBeatMessage((HeartBeatMessage)m, p);
             }
             else if (m.GetType().Equals(typeof(SystemMessage)))
             {
                 handleSystemMessage((SystemMessage)m, p);
             }
             else if (m.GetType().Equals(typeof(ChatMessage)))
             {
                 handleChatMessage((ChatMessage)m, p);
             }
             else if (m.GetType().Equals(typeof(ReadyMessage)))
             {
                 handleReadyMessage((ReadyMessage)m, p);
             }
             else if (m.GetType().Equals(typeof(ChangeNameMessage)))
             {
                 handleChangeNameMessage((ChangeNameMessage)m, p);
             }
             else if (m.GetType().Equals(typeof(PlayOnGroupMessage)))
             {
                 handlePlayOnGroupMessage((PlayOnGroupMessage)m, p);
             }
             else if (m.GetType().Equals(typeof(MeldMessage)))
             {
                 handleMeldMessage((MeldMessage)m, p);
             }
             else if (m.GetType().Equals(typeof(GetTopDiscardMessage)))
             {
                 handleGetTopDiscardMessage((GetTopDiscardMessage)m, p);
             }
             else if (m.GetType().Equals(typeof(GetTopDeckCardMessage)))
             {
                 handleGetTopDeckCardMessage((GetTopDeckCardMessage)m, p);
             }
             else if (m.GetType().Equals(typeof(DiscardSkipMessage)))
             {
                 handleDiscardSkipMessage((DiscardSkipMessage)m, p);
             }
             else if (m.GetType().Equals(typeof(DiscardMessage)))
             {
                 handleDiscardMessage((DiscardMessage)m, p);
             }
             else if (m.GetType().Equals(typeof(RequestHandMessage)))
             {
                 handleRequestHandMessage((RequestHandMessage)m, p);
             }
             else if (m.GetType().Equals(typeof(RequestTableMessage)))
             {
                 handleRequestTableMessage((RequestTableMessage)m, p);
             }
             else
             {
                 UnknownMessage um = (UnknownMessage)m;
                 PhazeXLog.LogError
                 (
                     new Exception("Unknown message from client received! [" + um.Identifier + "]")
                     , GameLibraryVersion.ProgramIdentifier
                     , 108
                 );
             }
         }
         catch (BadMessageException bme)
         {
             PhazeXLog.LogError
             (
                 bme
                 , GameLibraryVersion.ProgramIdentifier
                 , 0
             );
         }
     }
 }
Ejemplo n.º 19
0
        public static WsjtxMessage Parse(byte[] datagram)
        {
            if (!CheckMagicNumber(datagram))
            {
                return(null);
            }

            int cur = MAGIC_NUMBER_LENGTH;

            int schemaVersion = DecodeQInt32(datagram, ref cur);
            var messageType   = (MessageType)DecodeQInt32(datagram, ref cur);

            try
            {
                if (schemaVersion == 2)
                {
                    WsjtxMessage result;

                    if (messageType == MessageType.HEARTBEAT_MESSAGE_TYPE)
                    {
                        result = HeartbeatMessage.Parse(datagram);
                    }
                    else if (messageType == MessageType.STATUS_MESSAGE_TYPE)
                    {
                        result = StatusMessage.Parse(datagram);
                    }
                    else if (messageType == MessageType.DECODE_MESSAGE_TYPE)
                    {
                        result = DecodeMessage.Parse(datagram);
                    }
                    else if (messageType == MessageType.CLEAR_MESSAGE_TYPE)
                    {
                        result = ClearMessage.Parse(datagram);
                    }
                    else if (messageType == MessageType.QSO_LOGGED_MESSAGE_TYPE)
                    {
                        result = QsoLoggedMessage.Parse(datagram);
                    }
                    else if (messageType == MessageType.CLOSE_MESSAGE_TYPE)
                    {
                        result = CloseMessage.Parse(datagram);
                    }
                    else if (messageType == MessageType.WSPR_DECODE_MESSAGE_TYPE)
                    {
                        result = WsprDecodeMessage.Parse(datagram);
                    }
                    else if (messageType == MessageType.LOGGED_ADIF_MESSAGE_TYPE)
                    {
                        result = LoggedAdifMessage.Parse(datagram);
                    }
                    else
                    {
                        result = new UnknownMessage();
                    }

                    result.Datagram = datagram;

                    return(result);
                }
            }
            catch (Exception ex)
            {
                throw new ParseFailureException(messageType, datagram, ex);
            }

            throw new NotImplementedException($"Schema version {schemaVersion}, message type {messageType}");
        }
Ejemplo n.º 20
0
        protected Message getMessage()
        {
            byte[] b;
            int    avail;

            try
            {
                //while we're here, look for data in the buffer
                avail = _sock.Available;
                if (avail > 0)
                {
                    buffer.ReadFromSocket(_sock, avail);

                    this.BytesReceived += avail;
                }

                //first see if we can actually decode something
                if (buffer.CanDecode())
                {
                    b = buffer.Decode();
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                PhazeXLog.LogError(ex, GameLibraryVersion.VersionString, 104);
                _connected = false;
                return(null);
            }



            Message m = null;

            if (b.Length == 0)
            {
                return(m);
            }
            else if (b[0] == (byte)pxMessages.Heartbeat)
            {
                m = new HeartBeatMessage(b);
            }
            else if (b[0] == (byte)pxMessages.ChangeName)
            {
                m = new ChangeNameMessage(b, this.GetPlayerIDs());
            }
            else if (b[0] == (byte)pxMessages.ChangeNameReject)
            {
                m = new ChangeNameRejectMessage(b);
            }
            else if (b[0] == (byte)pxMessages.Chat)
            {
                m = new ChatMessage(b, this.GetPlayerIDs());
            }
            else if (b[0] == (byte)pxMessages.CompletedPhaze)
            {
                m = new CompletedPhazeMessage(b, this.GetPlayerIDs());
            }
            else if (b[0] == (byte)pxMessages.CurrentPhaze)
            {
                m = new CurrentPhazeMessage(b, this.GameRules);
            }
            else if (b[0] == (byte)pxMessages.DiscardSkip)
            {
                m = new DiscardSkipMessage(b, this.GetPlayerIDs(), this.GameRules);
            }
            else if (b[0] == (byte)pxMessages.DialogMessage)
            {
                m = new DialogMessage(b);
            }
            else if (b[0] == (byte)pxMessages.ErrorMessage)
            {
                m = new ErrorMessage(b);
            }
            else if (b[0] == (byte)pxMessages.GameOver)
            {
                m = new GameOverMessage(b);
            }
            else if (b[0] == (byte)pxMessages.GameRules)
            {
                m = new GameRulesMessage(b);
            }
            else if (b[0] == (byte)pxMessages.GameStarting)
            {
                m = new GameStartingMessage(b);
            }
            else if (b[0] == (byte)pxMessages.Goodbye)
            {
                m = new GoodbyeMessage(b);
            }
            else if (b[0] == (byte)pxMessages.GotCards)
            {
                m = new GotCardsMessage(b, this.GameRules);
            }
            else if (b[0] == (byte)pxMessages.GotDeckCard)
            {
                m = new GotDeckCardMessage(b, this.GetPlayerIDs());
            }
            else if (b[0] == (byte)pxMessages.GotDiscard)
            {
                m = new GotDiscardMessage(b, this.GetPlayerIDs(), this.GameRules);
            }
            else if (b[0] == (byte)pxMessages.Hand)
            {
                m = new HandMessage(b, this.GameRules);
            }
            else if (b[0] == (byte)pxMessages.Login)
            {
                m = new LoginMessage(b);
            }
            else if (b[0] == (byte)pxMessages.LoginAcknowledgment)
            {
                m = new LoginAckMessage(b);
            }
            else if (b[0] == (byte)pxMessages.LogOff)
            {
                m = new LogOffMessage(b, this.GetPlayerIDs());
            }
            else if (b[0] == (byte)pxMessages.NewHand)
            {
                m = new NewHandMessage(b);
            }
            else if (b[0] == (byte)pxMessages.PlayedCardOnTable)
            {
                m = new PlayedCardOnTableMessage(b, this.GetPlayerIDs(), this.GameRules);
            }
            else if (b[0] == (byte)pxMessages.Ready)
            {
                m = new ReadyMessage(b, this.GetPlayerIDs());
            }
            else if (b[0] == (byte)pxMessages.Scoreboard)
            {
                m = new ScoreboardMessage(b, this.GetPlayerIDs(), this.GameRules);
            }
            else if (b[0] == (byte)pxMessages.SkipNotification)
            {
                m = new SkipNotificationMessage(b, this.GetPlayerIDs());
            }
            else if (b[0] == (byte)pxMessages.StartGameTimer)
            {
                m = new StartGameTimerMessage(b);
            }
            else if (b[0] == (byte)pxMessages.Status)
            {
                m = new StatusMessage(b, this.GetPlayerIDs(), this.GameRules);
            }
            else if (b[0] == (byte)pxMessages.SystemMessage)
            {
                m = new SystemMessage(b);
            }
            else if (b[0] == (byte)pxMessages.Table)
            {
                m = new TableMessage(b, this.GameRules);
            }
            else if (b[0] == (byte)pxMessages.TurnEnd)
            {
                m = new TurnEndMessage(b, this.GetPlayerIDs());
            }
            else if (b[0] == (byte)pxMessages.TurnStart)
            {
                m = new TurnStartMessage(b, this.GetPlayerIDs());
            }
            else if (b[0] == (byte)pxMessages.UpdateDiscard)
            {
                m = new UpdateDiscardMessage(b, this.GetPlayerIDs(), this.GameRules);
            }
            else if (b[0] == (byte)pxMessages.WentOut)
            {
                m = new WentOutMessage(b, this.GetPlayerIDs());
            }
            else if (b[0] == (byte)pxMessages.Won)
            {
                m = new WonMessage(b, this.GetPlayerIDs());
            }
            else
            {
                m = new UnknownMessage(b);
            }

            return(m);
        }