public void RequestPreviousMessages(string messageId, RoomViewModel room) { _client.GetPreviousMessages(messageId) .ContinueWith(_ => { var messages = ProcessMessages(_.Result); PostOnUi(() => room.AddPreviousMessages(messages)); }); }
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)); }); }); }
public void LeaveRoom(RoomViewModel roomViewModel) { _client.LeaveRoom(roomViewModel.RoomName).ContinueWith( task => PostOnUi(() => roomViewModel.JoinState = JoinState.NotJoined), TaskContinuationOptions.OnlyOnRanToCompletion); }
private void OnJoiningRoom(RoomViewModel room) { EventHandler<JoiningRoomEventArgs> handler = JoiningRoom; if (handler != null) PostOnUi(() => handler(this, new JoiningRoomEventArgs(room))); }
private void InvokeIfInRoom(RoomViewModel room, Action<RoomViewModel> toInvoke) { if (room == null || room.JoinState != JoinState.Joined) return; toInvoke(room); }
public JoiningRoomEventArgs(RoomViewModel room) { Room = room; }