本文整理汇总了C#中Bunny.Core.Client.Disconnect方法的典型用法代码示例。如果您正苦于以下问题:C# Client.Disconnect方法的具体用法?C# Client.Disconnect怎么用?C# Client.Disconnect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bunny.Core.Client
的用法示例。
在下文中一共展示了Client.Disconnect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessDeleteChar
public static void ProcessDeleteChar(Client client, PacketReader packetReader)
{
var uid = packetReader.ReadMuid();
var index = packetReader.ReadInt32();
var name = packetReader.ReadString();
var result = Results.Accepted;
if (uid != client.GetMuid() || !Globals.AcceptedString.IsMatch(name) || index < 0 || index > 4)
{
client.Disconnect();
return;
}
var cid = Globals.GunzDatabase.GetCid(client.ClientPlayer.PlayerAccount.AccountId, index);
if (cid == 0)
{
result = Results.CharacterDeleteDisabled;
}
else
{
Globals.GunzDatabase.DeleteCharacter(client.ClientPlayer.PlayerAccount.AccountId, cid);
}
Match.ResponseDeleteCharacter(client, result);
}
示例2: ProcessCreateChar
public static void ProcessCreateChar(Client client, PacketReader packetReader)
{
var uid = packetReader.ReadMuid();
var index = packetReader.ReadInt32();
var name = packetReader.ReadString();
var sex = packetReader.ReadInt32();
var hair = packetReader.ReadInt32();
var face = packetReader.ReadInt32();
var costume = packetReader.ReadInt32();
var result = Results.Accepted;
if (uid != client.GetMuid() || index < 0 || index > 4 || sex < 0 || sex > 1)
{
client.Disconnect();
return;
}
if (!Globals.AcceptedString.IsMatch(name))
result = Results.CharacterEnterName;
else if (Globals.GunzDatabase.GetCharacterCount(client.ClientPlayer.PlayerAccount.AccountId) >= 4)
result = Results.CharacterNameNonExistant;
else if (Globals.GunzDatabase.CharacterExists(name))
result = Results.CharacterNameInUse;
else if (!Globals.GunzDatabase.CreateCharacter(client.ClientPlayer.PlayerAccount.AccountId, (byte)index, name, sex, hair, face, costume))
result = Results.CharacterInvalidName;
Match.ResponseCreateChar(client, result, name);
}
示例3: ProcessAdminAnnounce
public static void ProcessAdminAnnounce(Client client, PacketReader packetReader)
{
var adminId = packetReader.ReadMuid();
var message = packetReader.ReadString();
if (client.ClientPlayer.PlayerAccount.Access == UGradeId.Administrator
|| client.ClientPlayer.PlayerAccount.Access == UGradeId.Developer
|| client.ClientPlayer.PlayerAccount.Access == UGradeId.EventMaster)
{
Match.Announce(client, message);
return;
}
client.Disconnect();
return;
}
示例4: ProcessCharInfo
public static void ProcessCharInfo(Client client, PacketReader packetReader)
{
var index = packetReader.ReadByte();
if (index < 0 || index > 4)
{
client.Disconnect();
return;
}
client.GetCharacter().CharNum = index;
client.GetCharacter().UGrade = client.ClientPlayer.PlayerAccount.Access;
Globals.GunzDatabase.GetCharacter(client.ClientPlayer.PlayerAccount.AccountId, index, client.GetCharacter());
Match.ResponseCharInfo(client);
}
示例5: ProcessChannelList
public static void ProcessChannelList(Client client, PacketReader packetReader)
{
var uid = packetReader.ReadUInt64();
var type = packetReader.ReadInt32();
if (!Enum.IsDefined(typeof (ChannelType), (byte) type))
{
client.Disconnect();
return;
}
var channels = ChannelList.GetList((ChannelType)type);
if (channels.Count == 0)
return;
ChannelPackets.ResponseChannelList(client, channels);
}
示例6: ProcessEquipItem
public static void ProcessEquipItem(Client client, PacketReader packetReader)
{
var uidChar = packetReader.ReadUInt64();
var nItemLow = packetReader.ReadInt32();
var nItemHigh = packetReader.ReadInt32();
var nItemSlot = packetReader.ReadInt32();
Results result = Results.Accepted;
if (!Enum.IsDefined(typeof(ItemSlotType), nItemSlot))
{
client.Disconnect();
return;
}
Items.Item nItem = client.GetCharacter().Items.Find(i => i.ItemCid == nItemHigh);
if (nItem == null)
result = Results.ShopItemNonExistant;
else if (nItem.Level > client.GetCharacter().Level)
{
result = Results.ShopLevelTooLow;
}
else if ((ItemSlotType)nItemSlot == ItemSlotType.primary_slot && nItem.ItemId == client.GetCharacter().EquippedItems[(int)ItemSlotType.secondary_slot].ItemId)
{
result = Results.ShopInvalidItem;
}
else if ((ItemSlotType)nItemSlot == ItemSlotType.secondary_slot && nItem.ItemId == client.GetCharacter().EquippedItems[(int)ItemSlotType.primary_slot].ItemId)
{
result = Results.ShopInvalidItem;
}
else
{
client.GetCharacter().EquippedItems[nItemSlot].ItemCid = nItemHigh;
client.GetCharacter().EquippedItems[nItemSlot].ItemId = nItem.ItemId;
Globals.GunzDatabase.UpdateSlot(client.GetCharacter().CharacterId, (ItemSlotType)nItemSlot, nItemHigh);
}
Match.ResponseEquipItem(client, result);
Match.ResponseCharacterItemList(client);
}
示例7: ProcessStageSetting
public static void ProcessStageSetting(Client client, PacketReader packetReader)
{
if (client.GetStage() == null)
return;
var stage = client.GetStage().GetTraits();
var uidChar = packetReader.ReadMuid();
var uidStage = packetReader.ReadMuid();
var total = packetReader.ReadInt32();
var size = packetReader.ReadInt32();
var count = packetReader.ReadInt32();
var uidStage2 = packetReader.ReadMuid();
var map = packetReader.ReadString(32);
var index = packetReader.ReadInt32();
var type = packetReader.ReadInt32();
var rounds = packetReader.ReadInt32();
var time = packetReader.ReadInt32();
var level = packetReader.ReadInt32();
var players = packetReader.ReadInt32();
var teamkill = packetReader.ReadBoolean();
var balance = packetReader.ReadBoolean();
var join = packetReader.ReadBoolean();
var win = packetReader.ReadBoolean();
if ((ObjectStageGameType)type != stage.Gametype)
{
if (!Enum.IsDefined(typeof(ObjectStageGameType), (byte)type))
{
client.Disconnect();
return;
}
stage.Gametype = (ObjectStageGameType)type;
}
switch ((ObjectStageGameType)type)
{
case ObjectStageGameType.DeathMatch:
stage.Ruleset = new Deathmatch(client.GetStage());
break;
case ObjectStageGameType.Berserker:
stage.Ruleset = new Berserker(client.GetStage());
break;
case ObjectStageGameType.Duel:
stage.Ruleset = new Duel(client.GetStage());
break;
case ObjectStageGameType.Gladiator:
stage.Ruleset = new Deathmatch(client.GetStage());
break;
case ObjectStageGameType.Training:
stage.Ruleset = new Deathmatch(client.GetStage());
break;
case ObjectStageGameType.TeamDeathMatch:
stage.Ruleset = new TeamDeathmatch(client.GetStage());
break;
case ObjectStageGameType.TeamGladiator:
stage.Ruleset = new TeamDeathmatch(client.GetStage());
break;
case ObjectStageGameType.Assassination:
stage.Ruleset = new Assassination(client.GetStage());
break;
case ObjectStageGameType.TeamDeathMatchExtreme:
stage.Ruleset = new TeamDeathmatchExtreme(client.GetStage());
break;
default:
Log.Write("Unknown ruleset: {0}", type);
stage.Ruleset = new Deathmatch(client.GetStage());
break;
}
stage.RoundCount = rounds;
stage.Time = time > Byte.MaxValue ? (byte)0 : Convert.ToByte(time);
stage.Level = Convert.ToByte(level);
stage.MaxPlayers = Convert.ToByte(players);
stage.ForcedEntry = join;
stage.TeamBalanced = balance;
stage.TeamKill = teamkill;
if ((ObjectStageGameType)type == ObjectStageGameType.Duel && type != stage.Type)
{
stage.CurrentMap = Globals.Maps.GetMap("Hall");
stage.Map = "Hall";
}
else
{
stage.Type = type;
}
client.GetStage().Settings(client, true);
Channel.Refresh(client);
}
示例8: ProcessStageMap
public static void ProcessStageMap(Client client, PacketReader packetReader)
{
var uid = packetReader.ReadMuid();
var map = packetReader.ReadString();
if (map.Length > 127 || client.GetStage() == null || client.GetStage().GetTraits().Master != client)
{
client.Disconnect();
return;
}
if (map != "RelayMap")
{
client.GetStage().GetTraits().RelayEnabled = false;
client.GetStage().GetTraits().Map = map;
try
{
client.GetStage().GetTraits().CurrentMap = Globals.Maps.GetMap(map);
}
catch
{
Log.Write("Unable to load map: {0}. Defaulting to Mansion", map);
client.GetStage().GetTraits().CurrentMap = Globals.Maps.GetMap("Mansion");
}
}
else
{
client.GetStage().GetTraits().RelayEnabled = true;
}
client.GetStage().Settings(client, true);
Channel.Refresh(client);
}
示例9: ProcessStageCreate
public static void ProcessStageCreate(Client client, PacketReader packetReader)
{
var uid = packetReader.ReadMuid();
var name = packetReader.ReadString();
var locked = packetReader.ReadBoolean();
var password = packetReader.ReadString();
if (uid != client.GetMuid())
{
client.Disconnect();
return;
}
var traits = new StageTraits();
traits.StageId = Globals.StageCounter.GetNext();
traits.Name = name;
traits.Locked = locked;
traits.Password = password;
traits.Master = client;
client.ClientPlayer.PlayerStage = client.GetChannel().Add(traits);
client.GetStage().Join(client);
}
示例10: ProcessRequestProposal
public static void ProcessRequestProposal(Client client, PacketReader packetReader)
{
var uid = packetReader.ReadMuid();
var mode = packetReader.ReadInt32();
var request = packetReader.ReadInt32();
var memberCount = packetReader.ReadInt32();
var totalSize = packetReader.ReadInt32();
var blobSize = packetReader.ReadInt32();
var blobCount = packetReader.ReadInt32();
List<byte[]> blob = new List<byte[]>();
if (memberCount == blobCount)
{
for (int i = 0; i < blobCount; ++i)
{
var temp = new byte[blobSize];
packetReader.Read(temp, 0, blobSize);
blob.Add(temp);
}
}
else
{
client.Disconnect();
return;
}
List<Client> requests = new List<Client>();
foreach (byte[] b in blob)
{
string s = System.Text.ASCIIEncoding.ASCII.GetString(b);
s = s.Substring(0, s.IndexOf('\0'));
requests.Add(TcpServer.GetClientFromName(s));
}
if (requests.FindAll(c => c.GetCharacter().ClanId == client.GetCharacter().ClanId).Count == memberCount)
{
List<Pair<Client, bool>> list = new List<Pair<Client, bool>>();
foreach (Client c in requests)
{
list.Add(new Pair<Client, bool>(c, false));
}
list.Add(new Pair<Client, bool>(client, true));
ClanPackets.AskAgreement(requests, client, mode, request);
ClanPackets.ResponseProposal(client, 0, mode, request);
PendingClanWarRequest pc = new PendingClanWarRequest();
pc.RequestId = request;
pc.Players = list;
pc.ClanName = client.GetCharacter().ClanName;
pc.Requester = client;
pc.RequestMode = mode;
lock(Globals.PendingClanWar)
Globals.PendingClanWar.Add(pc);
var responsetimer = new Timer(30000);
responsetimer.Elapsed += (s, o) => CancelClanWarRequest(client, pc, responsetimer);
responsetimer.Start();
}
}
示例11: ProcessPromoteMember
public static void ProcessPromoteMember(Client client, PacketReader packetReader)
{
if (client.GetCharacter().ClanId < 1 || client.GetCharacter().ClanGrade != ClanGrade.Master)
return;
var sender = packetReader.ReadMuid();
var member = packetReader.ReadString();
var rank = packetReader.ReadInt32();
if (!Enum.IsDefined(typeof(ClanGrade), rank))
{
client.Disconnect();
return;
}
Client memberClient = TcpServer.GetClientFromName(member);
if (memberClient != null)
{
memberClient.GetCharacter().ClanGrade = (ClanGrade)rank;
Globals.GunzDatabase.UpdateMember(memberClient.GetCharacter().CharacterId, rank);
}
ClanPackets.ResponseChangeGrade(client);
ClanPackets.UpdateClanCharInfo(memberClient);
ClanPackets.SendMemberList(client);
}
示例12: ProcessSelectChar
public static void ProcessSelectChar(Client client, PacketReader packetReader)
{
var uid = packetReader.ReadMuid();
var index = packetReader.ReadInt32();
if (uid != client.GetMuid() || index < 0 || index > 4)
{
client.Disconnect();
return;
}
client.ClientFlags = PacketFlags.Character;
Globals.GunzDatabase.GetCharacter(client.ClientPlayer.PlayerAccount.AccountId, (byte)index, client.GetCharacter());
Match.ResponseSelectCharacter(client);
}
示例13: ResponseChannelJoinFromName
public static void ResponseChannelJoinFromName(Client client, PacketReader packetReader)
{
var uid = packetReader.ReadUInt64();
var type = packetReader.ReadInt32();
var name = packetReader.ReadString();
if (!Enum.IsDefined(typeof(ChannelType), (byte)type))
{
client.Disconnect();
return;
}
Channels.Channel c = ChannelList.Find((ChannelType) type, name);
if (c == null)
{
var channel = new ChannelTraits();
channel.ChannelName = name;
channel.Rule = ChannelRule.Elite;
channel.Type = (ChannelType)type;
channel.MaxLevel = 100;
channel.MinLevel = 0;
channel.MaxUsers = 100;
ChannelList.AddAndJoin(client, channel);
return;
}
client.ClientPlayer.PlayerChannel = c;
c.Join(client);
}
示例14: ResponseStageState
public static void ResponseStageState(Client client, PacketReader packetReader)
{
var charId = packetReader.ReadMuid();
var stageId = packetReader.ReadMuid();
var state = packetReader.ReadInt32();
if (!Enum.IsDefined(typeof(ObjectStageState), state) || client.GetStage() == null)
{
client.Disconnect();
return;
}
client.ClientPlayer.PlayerState = (ObjectStageState)state;
client.GetStage().PlayerState(client);
}
示例15: ProcessLoginRequest
public static void ProcessLoginRequest(Client client, PacketReader packetReader)
{
var user = packetReader.ReadString();
var pass = packetReader.ReadString();
var version = packetReader.ReadInt32();
var checksum = packetReader.ReadInt32();
var totalSize = packetReader.ReadInt32();
var blobSize = packetReader.ReadInt32();
var blobCount = packetReader.ReadInt32();
var md5 = new byte[blobSize*blobCount];
packetReader.Read(md5, 0, blobSize);
if (blobSize > 32)
{
client.Disconnect();
return;
}
if (!Globals.AcceptedString.IsMatch(user) || !Globals.AcceptedString.IsMatch(pass))
{
Match.ResponseLogin(client, Results.LoginAuthenticationFailed, user, UGradeId.Guest, PGradeId.Free, new Muid(0,0));
client.Disconnect();
return;
}
if (Globals.Config.Server.AutoRegistration)
{
if (user.StartsWith("!r"))
{
user = user.Substring(2);
if (!Globals.GunzDatabase.AccountExists(user))
Globals.GunzDatabase.CreateAccount(user, pass, ref client.ClientPlayer.PlayerAccount);
else
{
Match.ResponseNotify(client, "That account is already in use!", 1);
client.Disconnect();
return;
}
}
else
Globals.GunzDatabase.GetAccount(user, pass, ref client.ClientPlayer.PlayerAccount);
}
else
Globals.GunzDatabase.GetAccount(user, pass, ref client.ClientPlayer.PlayerAccount);
if (client.ClientPlayer.PlayerAccount.AccountId == 0)
{
Match.ResponseLogin(client, Results.LoginIncorrectPassword, user, UGradeId.Guest, PGradeId.Free, new Muid(0, 0));
client.Disconnect();
return;
}
if (client.ClientPlayer.PlayerAccount.Access == UGradeId.Banned || client.ClientPlayer.PlayerAccount.Access == UGradeId.Criminal)
{
Match.ResponseLogin(client, Results.LoginBannedId, user, UGradeId.Guest, PGradeId.Free, new Muid(0, 0));
client.Disconnect();
return;
}
if (version != Globals.Config.Client.Version)
{
Match.ResponseLogin(client, Results.LoginInvalidVersion, user, UGradeId.Guest, PGradeId.Free, new Muid(0, 0));
return;
}
if (Globals.Config.Client.UseCrc)
{
if ((checksum^0) != Globals.Config.Client.FileList)
{
Match.ResponseLogin(client, Results.LoginInvalidVersion, user, UGradeId.Guest, PGradeId.Free, new Muid(0, 0));
client.Disconnect();
return;
}
}
var inuse = TcpServer.GetClientFromAid(client.ClientPlayer.PlayerAccount.AccountId);
if (inuse != null && inuse != client)
{
inuse.Disconnect();
}
client.ClientFlags = PacketFlags.Login;
Match.ResponseLogin(client, Results.Accepted, user, client.ClientPlayer.PlayerAccount.Access, PGradeId.Free, client.GetMuid());
}