private void userlogout(packet data, bool expected)
{
mutTable.WaitOne();
if (_client_table.ContainsKey(data.Name))
{
try
{
availableusers.Remove(data.Name);
}
catch { }
string[] temp=null;
foreach (string[] ss in match)
{
if (ss.Contains(data.Name))
{
string oppo = (ss[0] == data.Name) ? ss[1] : ss[0];
packet p = new packet("q", null, null, 0, 0, 0, false);
sendPacket(oppo, p);
temp = ss;
}
}
try
{
match.Remove(temp);
}
catch { }
TcpClient client = _client_table[data.Name] as TcpClient;
_client_table.Remove(data.Name);
string msg = string.Format("{0} {1},現在線上人數: {2} \n", data.Name, (expected ? "已離線" : "意外中止"), _client_table.Count);
Console.WriteLine(msg);
client.Close();
}
mutTable.ReleaseMutex();
}