private async void crw_Closed(object sender, EventArgs e) { CreateRoomWindow crw = (CreateRoomWindow)sender; CreateRoomMessage crm = new CreateRoomMessage(); if (crw.Result==true) { crm.Name = crw.RoomName; crm.Password = crw.Password; crm.Capability = int.Parse(crw.Capability); Global.Status = BusyMessageEnum.CreatingRoom; ClientAnswer answer = await Global.NetworkClient.SendMessage(crm); Global.Status = BusyMessageEnum.None; if (!answer.Result) Error = answer.Message; } OnPropertyChanged("Error"); OnPropertyChanged("HasError"); }
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; }