示例#1
0
 public void RequestPreviousMessages(string messageId, RoomViewModel room)
 {
     _client.GetPreviousMessages(messageId)
         .ContinueWith(_ =>
                           {
                               var messages = ProcessMessages(_.Result);
                               PostOnUi(() => room.AddPreviousMessages(messages));
                           });
 }
示例#2
0
        public Task JoinRoom(RoomViewModel roomViewModel)
        {
            roomViewModel.JoinState = JoinState.Joining;
            OnJoiningRoom(roomViewModel);

            return _client.JoinRoom(roomViewModel.RoomName).ContinueWith(task =>
            {
                _client.GetRoomInfo(roomViewModel.RoomName).ContinueWith(details =>
                {
                    Room roomInfo = details.Result;
                    RoomViewModel roomVm = GetRoom(roomInfo.Name);
                    PostOnUi(() => roomVm.OnJoined(roomInfo));
                });
            });
        }
示例#3
0
 public void LeaveRoom(RoomViewModel roomViewModel)
 {
     _client.LeaveRoom(roomViewModel.RoomName).ContinueWith(
         task => PostOnUi(() => roomViewModel.JoinState = JoinState.NotJoined),
         TaskContinuationOptions.OnlyOnRanToCompletion);
 }
示例#4
0
 private void OnJoiningRoom(RoomViewModel room)
 {
     EventHandler<JoiningRoomEventArgs> handler = JoiningRoom;
     if (handler != null)
         PostOnUi(() => handler(this, new JoiningRoomEventArgs(room)));
 }
示例#5
0
        private void InvokeIfInRoom(RoomViewModel room, Action<RoomViewModel> toInvoke)
        {
            if (room == null || room.JoinState != JoinState.Joined)
                return;

            toInvoke(room);
        }
示例#6
0
 public JoiningRoomEventArgs(RoomViewModel room)
 {
     Room = room;
 }