Esempio n. 1
0
 public ServerRoom(Lobby lobby, User host, string roomName, bool isEncrypted, string password)
     : base(host, roomName, isEncrypted, password)
 {
     this.lobby = lobby;
     roomCount++;
     id = roomCount;
 }
 private void PrintLobby(Lobby lobby)
 {
     foreach (Room room in lobby.rooms.Values)
     {
         Console.WriteLine("Name: "+room.id + ". " + room.name);
         Console.WriteLine("lock: "+room.isEncrypted);
         Console.WriteLine("password: "+room.password);
         foreach (User user in room.users.Values)
         {
             Console.WriteLine(user.userName);
         }
     }
 }
 private void LobbyUpdateBroadcast(Lobby lobby)
 {
     Dictionary<byte, object> parameter = new Dictionary<byte, object>
                                 {
                                     {(byte)LobbyStatusChangeBroadcastParameterItem.LobbyDataString, JsonConvert.SerializeObject(lobby.Serialize(), new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Auto }) }
                                 };
     List<Peer> peers = new List<Peer>();
     foreach (ServerUser targetUser in server.lobby.users.Values)
     {
         peers.Add(targetUser.Peer);
     }
     server.Broadcast(peers.ToArray(), BroadcastType.LobbyStatusChange, parameter);
 }