Here we have the Connect(); function:
public static void Connect(string username, string password, string roomName, string roomType, string roomID, string roomPass, bool roomVisible)
{
Console.WriteLine("[Bot] Trying to login...");
PlayerIO.QuickConnect.SimpleConnect("everybody-edits-su9rn58o40itdbnw69plyw", username, password,
delegate(Client client)
{
Console.WriteLine("[Bot] Logged in. Trying to join the room...");
Dictionary<string, string> roomData = new Dictionary<string, string>();
Dictionary<string, string> joinData = new Dictionary<string, string>();
roomData.Add("editkey", roomPass);
roomData.Add("name", roomName);
joinData.Add("editkey", roomPass);
try
{
con = client.Multiplayer.CreateJoinRoom(roomID, roomType, roomVisible, roomData, joinData);
if (con.Connected)
{
con.Send("init");
con.Send("init2");
con.OnMessage += new MessageReceivedEventHandler(OnMessage);
con.OnDisconnect += delegate(object sender, string reason)
{
Console.WriteLine("Disconnected, Error: " + reason);
};
Console.WriteLine("[Bot] Joined the world.");
}
}
catch (PlayerIOError error)
{
Console.WriteLine("Error: " + error);
}
},
delegate(PlayerIOError error)
{
Console.WriteLine("Error: " + error);
});
}
The ultimate goal is to disconnect, and my friend tells me this can be done with the use of a list. I am not familiar with lists, nor do I know how to use them.
What I am asking is to put this in ‘List’ form so that (I’m assuming…) we can use a ‘Clear’ method to possibly disconnect. Or maybe a ‘Remove’ method.
But like I said, I’m not sure how to use Lists at all, so the Clear method might mean something completely different.
Please ask if you need to know more about this function, I’ll try to get back as soon as possible. But from the vague information I have about lists, you don’t need to know every detail of the function.
What your friend is trying to say is that you need to maintain a list of your connections. A List is simply an object that will maintain your references.
Once you are done with all of the connections you can go through the list and “log off” or otherwise disconnect from those channels.