当前位置: 首页>>代码示例>>C#>>正文


C# Client.Kick方法代码示例

本文整理汇总了C#中Chraft.Net.Client.Kick方法的典型用法代码示例。如果您正苦于以下问题:C# Client.Kick方法的具体用法?C# Client.Kick怎么用?C# Client.Kick使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Chraft.Net.Client的用法示例。


在下文中一共展示了Client.Kick方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HandlePacketServerListPing

 public static void HandlePacketServerListPing(Client client, ServerListPingPacket packet)
 {
     // Received a ServerListPing, so send back Disconnect with the Reason string containing data (server description, number of users, number of slots), delimited by a §
     var clientCount = client.Owner.Server.GetAuthenticatedClients().Count();
     //client.SendPacket(new DisconnectPacket() { Reason = String.Format("{0}§{1}§{2}", client.Owner.Server.ToString(), clientCount, Chraft.Properties.Settings.Default.MaxPlayers) });
     client.Kick(String.Format("{0}§{1}§{2}", client.Owner.Server.ToString(), clientCount, Chraft.Properties.Settings.Default.MaxPlayers));
 }
开发者ID:AVATAR-Phoenix,项目名称:c-raft,代码行数:7,代码来源:Client.Recv.cs

示例2: HandlePacketCreativeInventoryAction

 public static void HandlePacketCreativeInventoryAction(Client client, CreativeInventoryActionPacket packet)
 {
     if (client.Owner.GameMode == 1)
         client.Owner.Inventory[packet.Slot] = new ItemStack(packet.ItemID, (sbyte)packet.Quantity, packet.Damage);
     else
         client.Kick("Invalid action: CreativeInventoryAction");
 }
开发者ID:AVATAR-Phoenix,项目名称:c-raft,代码行数:7,代码来源:Client.Recv.cs

示例3: HandlePacketLoginRequest

        public static void HandlePacketLoginRequest(Client client, LoginRequestPacket packet)
        {
            if (!client.Owner.CheckUsername(packet.Username))
                client.Kick("Inconsistent username");
            else if (packet.ProtocolOrEntityId < ProtocolVersion)
                client.Kick("Outdated client");
            else
            {
                if (client.Owner.Server.UseOfficalAuthentication)
                {
                    try
                    {
                        string authenticated = Http.GetHttpResponse(new Uri(String.Format("http://www.minecraft.net/game/checkserver.jsp?user={0}&serverId={1}", packet.Username, client.Owner.Server.ServerHash)));
                        if (authenticated != "YES")
                        {
                            client.Kick("Authentication failed");
                            return;
                        }
                    }
                    catch (Exception exc)
                    {
                        client.Kick("Error while authenticating...");
                        client.Logger.Log(exc);
                        return;
                    }
                }

                client.SendLoginSequence();
            }
        }
开发者ID:AVATAR-Phoenix,项目名称:c-raft,代码行数:30,代码来源:Client.Recv.cs

示例4: HandlePacketEncryptionResponse

        public static void HandlePacketEncryptionResponse(Client client, EncryptionKeyResponse packet)
        {
            client.SharedKey = PacketCryptography.Decrypt(packet.SharedSecret);

            RijndaelManaged recv = PacketCryptography.GenerateAES(client.SharedKey);
            RijndaelManaged send = PacketCryptography.GenerateAES(client.SharedKey);

            client.Decrypter = recv.CreateDecryptor();
            
            byte[] packetToken = PacketCryptography.Decrypt(packet.VerifyToken);

            if (!packetToken.SequenceEqual(PacketCryptography.VerifyToken))
            {
                client.Kick("Wrong token");
                return;
            }

            client.Send_Sync_Packet(new EncryptionKeyResponse());

            client.Encrypter = send.CreateEncryptor();

        }
开发者ID:TheaP,项目名称:c-raft,代码行数:22,代码来源:Client.Recv.cs

示例5: HandlePacketCreativeInventoryAction

        public static void HandlePacketCreativeInventoryAction(Client client, CreativeInventoryActionPacket packet)
        {
            if (client.Owner.GameMode == 1)

                if (packet.Item.Type == -1 && packet.Item.Durability == 0 && packet.Item.Count == 0) // We are adding an item to our mouse cursor from the quick bar
                {
                    //may need to do something here
                    return;
                }
                else
                {
                    if (packet.Slot != -1)// mouse cursor mode
                    {
                        client.Owner.Inventory[packet.Slot] = packet.Item;
                    }

                }
            else
                client.Kick("Invalid action: CreativeInventoryAction");
        }
开发者ID:dekema2,项目名称:c-raft,代码行数:20,代码来源:Client.Recv.cs

示例6: HandlePacketHandshake

        public static void HandlePacketHandshake(Client client, HandshakePacket packet)
        {
            client.Username = packet.Username;
            if (!client.CheckUsername(packet.Username))
                client.Kick("Inconsistent username");
            if (packet.ProtocolVersion < ProtocolVersion)
                client.Kick("Outdated client");
            else
            {
                client.Host = packet.ServerHost + ":" + packet.ServerPort;

                if (client.Server.EncryptionEnabled)
                    client.SendEncryptionRequest();
                else if (IsAuthenticated(client))
                    Task.Factory.StartNew(client.SendLoginSequence);

            }
        }
开发者ID:TheaP,项目名称:c-raft,代码行数:18,代码来源:Client.Recv.cs

示例7: HandlePacketServerListPing

 public static void HandlePacketServerListPing(Client client, ServerListPingPacket packet)
 {
     // Received a ServerListPing, so send back Disconnect with the Reason string containing data (server description, number of users, number of slots), delimited by a §
     var clientCount = client.Server.GetAuthenticatedClients().Count();
     client.Kick(String.Format("§1\0{0}\0{1}\0{2}\0{3}\0{4}", ProtocolVersion, MinecraftServerVersion, ChraftConfig.MOTD, clientCount, ChraftConfig.MaxPlayers));
 }
开发者ID:TheaP,项目名称:c-raft,代码行数:6,代码来源:Client.Recv.cs

示例8: IsAuthenticated

        public static bool IsAuthenticated(Client client)
        {
            if (client.Server.UseOfficalAuthentication)
            {
                try
                {
                    var uri = new Uri(
                        String.Format(
                            "http://session.minecraft.net/game/checkserver.jsp?user={0}&serverId={1}",
                            client.Username,
                        // As per http://mc.kev009.com/Protocol_Encryption
                            PacketCryptography.JavaHexDigest(Encoding.UTF8.GetBytes(client.ConnectionId)
                                                                            .Concat(client.SharedKey)
                                                                            .Concat(PacketCryptography.PublicKeyToAsn1(client.Server.ServerKey))
                                                                            .ToArray())
                            ));

                    string authenticated = Http.GetHttpResponse(uri);
                    if (authenticated != "YES")
                    {
                        client.Kick("Authentication failed");
                        return false;
                    }
                }
                catch (Exception exc)
                {
                    client.Kick("Error while authenticating...");
                    client.Logger.Log(exc);
                    return false;
                }

                return true;
            }

            return true;
        }
开发者ID:TheaP,项目名称:c-raft,代码行数:36,代码来源:Client.Recv.cs

示例9: HandlePacketEncryptionResponse

        public static void HandlePacketEncryptionResponse(Client client, EncryptionKeyResponse packet)
        {
            client.SharedKey = PacketCryptography.Decrypt(packet.SharedSecret);

            RijndaelManaged recv = PacketCryptography.GenerateAES(client.SharedKey);
            RijndaelManaged send = PacketCryptography.GenerateAES(client.SharedKey);

            /*AesCryptoServiceProvider provider = new AesCryptoServiceProvider();
            provider.Mode = CipherMode.CFB;
            provider.FeedbackSize = 8;
            provider.KeySize = 128;
            provider.Key = client.SharedKey;
            provider.IV = client.SharedKey;*/

            client.Decrypter = recv.CreateDecryptor();

            byte[] packetToken;

            packetToken = PacketCryptography.Decrypt(packet.VerifyToken);

            if (!packetToken.SequenceEqual(PacketCryptography.VerifyToken))
            {
                client.Kick("Wrong token");
                return;
            }

            client.Send_Sync_Packet(new EncryptionKeyResponse());

            client.Encrypter = send.CreateEncryptor();
        }
开发者ID:UrbanLetsPlay,项目名称:c-raft,代码行数:30,代码来源:Client.Recv.cs

示例10: HandlePacketCreativeInventoryAction

        public static void HandlePacketCreativeInventoryAction(Client client, CreativeInventoryActionPacket packet)
        {
            if (client.Owner.GameMode == 1)

                if (packet.ItemID == -1 && packet.Damage == 0 && packet.Quantity == 0) // We are adding an item to our mouse cursor from the quick bar
                {
                    //may need to do something here
                    return;
                }
                else
                {
                    if (packet.Slot != -1)// mouse cursor mode
                    {
                        client.Owner.Inventory[packet.Slot] = new ItemStack(packet.ItemID, (sbyte)packet.Quantity, packet.Damage);
                    }

                }
            else
                client.Kick("Invalid action: CreativeInventoryAction");
        }
开发者ID:IdentErr,项目名称:c-raft,代码行数:20,代码来源:Client.Recv.cs


注:本文中的Chraft.Net.Client.Kick方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。