Do you think I could just leave this part blank and it'd be okay? We're just going to replace the whole thing with a header image anyway, right?
You are not logged in.
I'm recreating my old console chat client, this time with an option to browse all available rooms.
public static void GetRooms () {
Write ("Gathering rooms...");
cli = PlayerIO.QuickConnect.SimpleConnect ("everybody-edits-su9rn58o40itdbnw69plyw", "guest", "guest", null);
RoomInfo[] rooms = cli.Multiplayer.ListRooms ("Everybodyedits" + cli.BigDB.Load ("config", "config")["version"], null, 0, 0);
Clear ();
Write (rooms.Length + " rooms available.\nUse up/down arrow keys to browse rooms, Press Enter to select a room.\n\n");
foreach (RoomInfo room in rooms) {
Write (" " + room.Id + " - " + room.OnlineUsers + " users online.\n");
}
ReadKey (true);
}
The code is supposed to show the room ID, and the users online. However, I would like to show the user the room name, since the user is allowed to browse and select their specific room (they don't have to copy any ID).
Offline
I'm recreating my old console chat client, this time with an option to browse all available rooms.
public static void GetRooms () { Write ("Gathering rooms..."); cli = PlayerIO.QuickConnect.SimpleConnect ("everybody-edits-su9rn58o40itdbnw69plyw", "guest", "guest", null); RoomInfo[] rooms = cli.Multiplayer.ListRooms ("Everybodyedits" + cli.BigDB.Load ("config", "config")["version"], null, 0, 0); Clear (); Write (rooms.Length + " rooms available.\nUse up/down arrow keys to browse rooms, Press Enter to select a room.\n\n"); foreach (RoomInfo room in rooms) { Write (" " + room.Id + " - " + room.OnlineUsers + " users online.\n"); } ReadKey (true); }
The code is supposed to show the room ID, and the users online. However, I would like to show the user the room name, since the user is allowed to browse and select their specific room (they don't have to copy any ID).
room.data["name"]
or something
Offline
If you are going to answer to the entire topic, why would you quote it?
I was shared the method by capasha, which consists on gathering the name from RoomData.
foreach (RoomInfo room in rooms)
Write (" " + room.RoomData["name"] + (room.RoomData["name"].Length < 20 ? new string (' ', 20 - room.RoomData["name"].Length) : "" ) + " - " + room.OnlineUsers + " users online.\n");
Later I'll find my method to alphabetically sort rooms by name, then by online users.
Offline
...some things...
Later I'll find my method to alphabetically sort rooms by name, then by online users.
Id use Linq, its not particularly fast or efficient, but is easy to do:
rooms = rooms.OrderBy(some lambda expression e.g. r => r.OnlineUsers or r => r.RoomData["name"]).toArray();
ps not sure if this works as I'm on my phone so didnt test it, but it should
Offline
[ Started around 1732724502.2856 - Generated in 0.058 seconds, 12 queries executed - Memory usage: 1.4 MiB (Peak: 1.51 MiB) ]