public void RemovePlayer(string connectionId) { var player = playerRepository.GetByConnectionId(connectionId); if (player != null) { var room = roomRepository.GetByRoomId(player.RoomId); if (room != null) { room.Remove(player); if (room.IsRemovedAllPlayer) { AppSignalRLogger.Log("Remove Room {0}", room.RoomId); roomRepository.Remove(room); } else { roomRepository.Save(room); } } playerRepository.Remove(player); } }
public override Task OnDisconnectedAsync(Exception e) { AppSignalRLogger.Log("OnDisconnectedAsync {0}", Context.ConnectionId); appService.RemovePlayer(Context.ConnectionId); return(base.OnDisconnectedAsync(e)); }
public override Task OnConnectedAsync() { AppSignalRLogger.Log("OnConnected {0}", Context.ConnectionId); appService.AddPlayer(Context.ConnectionId); return(base.OnConnectedAsync()); }