本文整理汇总了C#中Yupi.Game.GameClients.Interfaces.GameClient.Disconnect方法的典型用法代码示例。如果您正苦于以下问题:C# GameClient.Disconnect方法的具体用法?C# GameClient.Disconnect怎么用?C# GameClient.Disconnect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Yupi.Game.GameClients.Interfaces.GameClient
的用法示例。
在下文中一共展示了GameClient.Disconnect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BanUser
/// <summary>
/// Bans the user.
/// </summary>
/// <param name="client">The client.</param>
/// <param name="moderator">The moderator.</param>
/// <param name="lengthSeconds">The length seconds.</param>
/// <param name="reason">The reason.</param>
/// <param name="ipBan">if set to <c>true</c> [ip ban].</param>
/// <param name="machine">if set to <c>true</c> [machine].</param>
internal void BanUser(GameClient client, string moderator, double lengthSeconds, string reason, bool ipBan,
bool machine)
{
ModerationBanType type = ModerationBanType.UserName;
string text = client.GetHabbo().UserName;
string typeStr = "user";
double num = Yupi.GetUnixTimeStamp() + lengthSeconds;
if (ipBan)
{
type = ModerationBanType.Ip;
using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
{
queryReactor.SetQuery("SELECT ip_last FROM users WHERE username = @name LIMIT 1");
queryReactor.AddParameter("name", text);
text = queryReactor.GetString();
}
typeStr = "ip";
}
if (machine)
{
type = ModerationBanType.Machine;
typeStr = "machine";
text = client.MachineId;
}
ModerationBan moderationBan = new ModerationBan(type, text, reason, num);
switch (moderationBan.Type)
{
case ModerationBanType.Ip:
if (_bannedIPs.Contains(text)) _bannedIPs[text] = moderationBan;
else _bannedIPs.Add(text, moderationBan);
break;
case ModerationBanType.Machine:
if (_bannedMachines.ContainsKey(text)) _bannedMachines[text] = moderationBan;
else _bannedMachines.Add(text, moderationBan);
break;
default:
if (_bannedUsernames.Contains(text)) _bannedUsernames[text] = moderationBan;
else _bannedUsernames.Add(text, moderationBan);
break;
}
using (IQueryAdapter queryreactor2 = Yupi.GetDatabaseManager().GetQueryReactor())
{
queryreactor2.SetQuery(
"INSERT INTO users_bans (bantype,value,reason,expire,added_by,added_date) VALUES (@rawvar,@var,@reason,@num,@mod,@time)");
queryreactor2.AddParameter("rawvar", typeStr);
queryreactor2.AddParameter("var", text);
queryreactor2.AddParameter("reason", reason);
queryreactor2.AddParameter("num", num);
queryreactor2.AddParameter("mod", moderator);
queryreactor2.AddParameter("time", DateTime.Now.ToLongDateString());
queryreactor2.RunQuery();
}
if (ipBan)
{
DataTable dataTable;
using (IQueryAdapter queryreactor3 = Yupi.GetDatabaseManager().GetQueryReactor())
{
queryreactor3.SetQuery("SELECT id FROM users WHERE ip_last = @var");
queryreactor3.AddParameter("var", text);
dataTable = queryreactor3.GetTable();
}
if (dataTable != null)
{
using (IQueryAdapter queryreactor4 = Yupi.GetDatabaseManager().GetQueryReactor())
{
foreach (DataRow dataRow in dataTable.Rows)
queryreactor4.RunFastQuery(
$"UPDATE users_info SET bans = bans + 1 WHERE user_id = {Convert.ToUInt32(dataRow["id"])}");
}
}
BanUser(client, moderator, lengthSeconds, reason, false, false);
return;
}
using (IQueryAdapter queryreactor5 = Yupi.GetDatabaseManager().GetQueryReactor())
queryreactor5.RunFastQuery(
$"UPDATE users_info SET bans = bans + 1 WHERE user_id = {client.GetHabbo().Id}");
client.Disconnect("banned");
//.........这里部分代码省略.........