Beispiel #1
0
 void CreateAuthMessage()
 {
     AuthorizationMessage msg = new AuthorizationMessage();
     //в сслыках не было указано ссылка на проект либы AncientHorrorShared который тест
 }
        public override BaseMessage GetInnerMessage()
        {
            switch (Type)
            {
                case AbonentsCommandType.Authorization:
                    {
                        AuthorizationMessage msg = new AuthorizationMessage();
                        msg.UTFDeSerialize(this.Message);
                        return msg;
                    }
                case AbonentsCommandType.UnAuthorization:
                    {
                        return new UnAuthorizationMessage() { MsgId = this.MsgId };
                    }
                case AbonentsCommandType.Exit:
                    {
                        return new ExitMessage() { MsgId = this.MsgId };
                    }
                case AbonentsCommandType.ExitRoom:
                    {
                        return new ExitRoomMessage() { MsgId = this.MsgId };
                    }
                case AbonentsCommandType.JoinRoom:
                    {
                        JoinRoomMessage msg = new JoinRoomMessage();
                        msg.UTFDeSerialize(this.Message);
                        return msg;
                    }
                case AbonentsCommandType.CreateRoom:
                    {
                        CreateRoomMessage msg = new CreateRoomMessage();
                        try
                        {
                            msg.UTFDeSerialize(this.Message);
                            return msg;
                        }
                        catch(Exception ex)
                        {

                        }
                        return msg;
                    }
                case AbonentsCommandType.RequestRoomInfo:
                    {
                        return new RequestRoomInfoMessage() { MsgId = this.MsgId };
                    }
                case AbonentsCommandType.StartRoom:
                    {
                        return new StartRoomMessage() { MsgId = this.MsgId };
                    }
                    case AbonentsCommandType.KickUser:
                    {
                        DataContractSerializer serializer = new DataContractSerializer(typeof(KickUserMessage));
                        using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(Message)))
                        {
                            KickUserMessage msg = (KickUserMessage)serializer.ReadObject(stream);
                            return msg;
                        }
                    }

            }
            return null;
        }