這裏我們有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);
});
}
最終目標是斷開連接,而我的朋友告訴我這可以通過使用列表完成。我不熟悉列表,也不知道如何使用它們。
我在問的是把它放在'List'表格中,這樣(我假設...)我們可以使用'Clear'方法來斷開連接。或者可能是一個'刪除'的方法。
但就像我說的,我不確定如何使用列表,所以Clear方法可能意味着完全不同的東西。
請問您是否需要了解更多關於此功能的信息,我會盡快回復。但是從我列出的模糊信息來看,你不需要知道函數的每個細節。
哈,大家來編輯。我似乎無法逃避那場比賽。 – Zenexer 2012-02-04 03:52:54