本文整理汇总了C#中MiNET.Player.Disconnect方法的典型用法代码示例。如果您正苦于以下问题:C# Player.Disconnect方法的具体用法?C# Player.Disconnect怎么用?C# Player.Disconnect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MiNET.Player
的用法示例。
在下文中一共展示了Player.Disconnect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Kick
public void Kick(Player player, string otherUser)
{
player.Level.BroadcastMessage(string.Format(ChatColors.Gold + "{0} tried to kick {1} but kicked self instead!!", player.Username, otherUser), type: MessageType.Raw);
player.Disconnect("You kicked yourself :-)");
}
示例2: HandleSplitMessage
private void HandleSplitMessage(PlayerNetworkSession playerSession, ConnectedPackage package, SplitPartPackage splitMessage, Player player)
{
int spId = package._splitPacketId;
int spIdx = package._splitPacketIndex;
int spCount = package._splitPacketCount;
if (!playerSession.Splits.ContainsKey(spId))
{
playerSession.Splits.TryAdd(spId, new SplitPartPackage[spCount]);
}
SplitPartPackage[] spPackets = playerSession.Splits[spId];
spPackets[spIdx] = splitMessage;
bool haveEmpty = false;
for (int i = 0; i < spPackets.Length; i++)
{
haveEmpty = haveEmpty || spPackets[i] == null;
}
if (!haveEmpty)
{
Log.DebugFormat("Got all {0} split packages for split ID: {1}", spCount, spId);
SplitPartPackage[] waste;
playerSession.Splits.TryRemove(spId, out waste);
MemoryStream stream = new MemoryStream();
for (int i = 0; i < spPackets.Length; i++)
{
SplitPartPackage splitPartPackage = spPackets[i];
byte[] buf = splitPartPackage.Message;
if (buf == null)
{
Log.Error("Expected bytes in splitpart, but got none");
continue;
}
stream.Write(buf, 0, buf.Length);
splitPartPackage.PutPool();
}
byte[] buffer = stream.ToArray();
try
{
Package fullMessage = PackageFactory.CreatePackage(buffer[1], buffer) ?? new UnknownPackage(buffer[1], buffer);
Log.Debug($"0x{fullMessage.Id:x2}\n{Package.HexDump(buffer)}");
fullMessage.DatagramSequenceNumber = package._datagramSequenceNumber;
fullMessage.ReliableMessageNumber = package._reliableMessageNumber;
fullMessage.OrderingChannel = package._orderingChannel;
fullMessage.OrderingIndex = package._orderingIndex;
HandlePackage(fullMessage, playerSession);
fullMessage.PutPool();
}
catch (Exception e)
{
player.Disconnect("Bad package received from client.");
}
}
}
示例3: Ban
public void Ban(Player player, string otherUser)
{
player.Level.BroadcastMessage(string.Format(ChatColors.Gold + "{0} tried to ban {1} but banned self instead!!", player.Username, otherUser), type: MessageType.Raw);
player.Disconnect("Oopps, banned the wrong player. See ya soon!!");
}