public bool EnterRoom() { Room room; if (CurrentSeat != null) { if (!ExitRoom()) { return(false); } } if (_IsSuccess(Connection.EnterRoom(_currentRoom.Id, false, null, out room))) { CurrentRoom = new RoomViewModel() { Room = room }; Trace.Assert(CurrentSeat != null, "Successfully joined a room, but do not find myself in the room"); return(true); } return(false); }
/// <summary> /// Updates all rooms in the lobby. /// </summary> public void UpdateRooms() { var result = _connection.GetRooms(_loginToken, false); Rooms.Clear(); bool found = false; foreach (var room in result) { var model = new RoomViewModel() { Room = room }; Rooms.Add(model); if (CurrentRoom != null && room.Id == CurrentRoom.Id) { found = true; CurrentRoom = model; } } if (!found) { CurrentRoom = null; } }
public void NotifyRoomUpdate(int id, Room room) { Application.Current.Dispatcher.BeginInvoke((ThreadStart)delegate() { var result = Rooms.FirstOrDefault(r => r.Id == id); if (result != null) { result.Room = room; } else { Rooms.Add(new RoomViewModel() { Room = room }); } if (CurrentRoom.Id == id) { CurrentRoom = new RoomViewModel() { Room = room }; } }); }
public bool EnterRoom() { Room room; if (CurrentSeat != null) { if (!ExitRoom()) return false; } if (_IsSuccess(Connection.EnterRoom(_loginToken, _currentRoom.Id, false, null, out room))) { CurrentRoom = new RoomViewModel() { Room = room }; Trace.Assert(CurrentSeat != null, "Successfully joined a room, but do not find myself in the room"); return true; } return false; }
/// <summary> /// Creates and enters a new room. /// </summary> public void CreateRoom() { var room = _connection.CreateRoom(_loginToken); if (room != null) { CurrentRoom = new RoomViewModel() { Room = room }; UpdateRooms(); Trace.Assert(CurrentSeat != null, "Successfully created a room, but do not find myself in the room"); } }
public void EnterRoom() { Room room; if (_connection.EnterRoom(_loginToken, _currentRoom.Id, false, null, out room) == RoomOperationResult.Success) { CurrentRoom = new RoomViewModel() { Room = room }; CurrentSeat = CurrentRoom.Seats.FirstOrDefault(s => s.Account != null && s.Account.Id == CurrentAccount.Id); Trace.Assert(CurrentSeat != null, "Successfully joined a room, but do not find myself in the room"); } }
/// <summary> /// Creates and enters a new room. /// </summary> public void CreateRoom() { var room = _connection.CreateRoom(_loginToken); if (room != null) { CurrentRoom = new RoomViewModel() { Room = room }; CurrentSeat = CurrentRoom.Seats.FirstOrDefault(s => s.Account != null && s.Account.Id == CurrentAccount.Id); Trace.Assert(CurrentSeat != null, "Successfully created a room, but do not find myself in the room"); } }