这里我们有 Connect();功能:
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);
});
}
最终目标是断开连接,我的 friend 告诉我这可以通过使用列表来完成。我不熟悉列表,也不知道如何使用它们。
我要问的是将它放在“列表”形式中,以便(我假设...)我们可以使用“清除”方法来可能断开连接。或者可能是“删除”方法。
但正如我所说,我完全不确定如何使用列表,因此 Clear 方法可能意味着完全不同的东西。
请询问您是否需要了解有关此功能的更多信息,我会尽快回复您。但是从我掌握的关于列表的模糊信息来看,您不需要了解函数的每个细节。
请您参考如下方法:
您的 friend 想说的是您需要维护一个联系人列表。列表只是一个将维护您的引用的对象。
完成所有连接后,您可以浏览列表并“注销”或以其他方式断开与这些 channel 的连接。
