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


C# Net.PacketReader类代码示例

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


PacketReader类属于Chraft.Net命名空间,在下文中一共展示了PacketReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReadKeepAlive

        public static void ReadKeepAlive(TestClient client, PacketReader reader)
        {
            KeepAlivePacket ka = new KeepAlivePacket();
            ka.Read(reader);

            if (!reader.Failed)
                TestClient.HandlePacketKeepAlive(client, ka);
        }
开发者ID:TheaP,项目名称:c-raft,代码行数:8,代码来源:PacketHandlers.cs

示例2: ItemStack

 internal ItemStack(PacketReader stream)
 {
     Type = stream.ReadShort();
     if (Type >= 0)
     {
         Count = stream.ReadSByte();
         Durability = stream.ReadShort();
     }
 }
开发者ID:IdentErr,项目名称:c-raft,代码行数:9,代码来源:ItemStack.cs

示例3: ItemStack

        internal ItemStack(PacketReader stream)
        {
            Type = stream.ReadShort();
            if (Type >= 0)
            {
                Count = stream.ReadSByte();
                Durability = stream.ReadShort();

                // TODO: Implement extra data read (enchantment) and items
                if (Durability > 0 || IsEnchantable())
                    stream.ReadShort();
            }
        }
开发者ID:UrbanLetsPlay,项目名称:c-raft,代码行数:13,代码来源:ItemStack.cs

示例4: MetaData

 internal MetaData(PacketReader rx)
 {
     byte x;
     while ((x = rx.ReadByte()) != 0x7f)
     {
         switch (x >> 5)
         {
             case 0: Data[x & 0x1f] = rx.ReadByte(); break;
             case 1: Data[x & 0x1f] = rx.ReadShort(); break;
             case 2: Data[x & 0x1f] = rx.ReadInt(); break;
             case 3: Data[x & 0x1f] = rx.ReadFloat(); break;
             case 4: Data[x & 0x1f] = rx.ReadString16(64); break;
             default: Data[x & 0x1f] = null; break;
         }
     }
 }
开发者ID:IdentErr,项目名称:c-raft,代码行数:16,代码来源:MetaData.cs

示例5: ReadUpdateHealth

 public static void ReadUpdateHealth(TestClient client, PacketReader reader)
 {
     UpdateHealthPacket uh = new UpdateHealthPacket();
     uh.Read(reader);
 }
开发者ID:Nirad,项目名称:c-raft,代码行数:5,代码来源:PacketHandlers.cs

示例6: ReadEntityTeleport

 public static void ReadEntityTeleport(TestClient client, PacketReader reader)
 {
     EntityTeleportPacket et = new EntityTeleportPacket();
     et.Read(reader);
 }
开发者ID:Nirad,项目名称:c-raft,代码行数:5,代码来源:PacketHandlers.cs

示例7: ReadTimeUpdate

 public static void ReadTimeUpdate(TestClient client, PacketReader reader)
 {
     TimeUpdatePacket tu = new TimeUpdatePacket();
     tu.Read(reader);
 }
开发者ID:Nirad,项目名称:c-raft,代码行数:5,代码来源:PacketHandlers.cs

示例8: ReadEntityMetadata

 public static void ReadEntityMetadata(TestClient client, PacketReader reader)
 {
     EntityMetadataPacket em = new EntityMetadataPacket();
     em.Read(reader);
 }
开发者ID:Nirad,项目名称:c-raft,代码行数:5,代码来源:PacketHandlers.cs

示例9: ProcessReadQueue

        public static void ProcessReadQueue()
        {
            int count = RecvClientQueue.Count;

            Parallel.For(0, count, i =>
            {
                Client client;
                if (!RecvClientQueue.TryDequeue(out client))
                    return;

                if (!client.Running)
                    return;

                Interlocked.Exchange(ref client.TimesEnqueuedForRecv, 0);
                ByteQueue bufferToProcess = client.GetBufferToProcess();

                int length = client.FragPackets.Size + bufferToProcess.Size;
                while (length > 0)
                {
                    byte packetType = 0;

                    if (client.FragPackets.Size > 0)
                        packetType = client.FragPackets.GetPacketID();
                    else
                        packetType = bufferToProcess.GetPacketID();

                    //client.Logger.Log(Chraft.Logger.LogLevel.Info, "Reading packet {0}", ((PacketType)packetType).ToString());

                    PacketHandler handler = PacketHandlers.GetHandler((PacketType)packetType);

                    if (handler == null)
                    {
                        byte[] unhandledPacketData = GetBufferToBeRead(bufferToProcess, client, length);

                        // TODO: handle this case, writing on the console a warning and/or writing it plus the bytes on a log
                        client.Logger.Log(Chraft.Logger.LogLevel.Caution, "Unhandled packet arrived, id: {0}", unhandledPacketData[0]);

                        client.Logger.Log(Chraft.Logger.LogLevel.Warning, "Data:\r\n {0}", BitConverter.ToString(unhandledPacketData, 1));
                        length = 0;
                    }
                    else if (handler.Length == 0)
                    {
                        byte[] data = GetBufferToBeRead(bufferToProcess, client, length);

                        if (length >= handler.MinimumLength)
                        {
                            PacketReader reader = new PacketReader(data, length, StreamRole.Server);

                            handler.OnReceive(client, reader);

                            // If we failed it's because the packet isn't complete
                            if (reader.Failed)
                            {
                                EnqueueFragment(client, data);
                                length = 0;
                            }
                            else
                            {
                                bufferToProcess.Enqueue(data, reader.Index, data.Length - reader.Index);
                                length = bufferToProcess.Length;
                            }
                        }
                        else
                            EnqueueFragment(client, data);

                    }
                    else if (length >= handler.Length)
                    {
                        byte[] data = GetBufferToBeRead(bufferToProcess, client, handler.Length);

                        PacketReader reader = new PacketReader(data, handler.Length, StreamRole.Server);

                        handler.OnReceive(client, reader);

                        // If we failed it's because the packet isn't complete
                        if (reader.Failed)
                        {
                            EnqueueFragment(client, data);
                            length = 0;
                        }
                        else
                            length = bufferToProcess.Length;
                    }
                    else
                    {
                        byte[] data = GetBufferToBeRead(bufferToProcess, client, length);
                        EnqueueFragment(client, data);
                        length = 0;
                    }
                }
            });
        }
开发者ID:IdentErr,项目名称:c-raft,代码行数:92,代码来源:Server.cs

示例10: ReadAnimation

 public static void ReadAnimation(TestClient client, PacketReader reader)
 {
     AnimationPacket ap = new AnimationPacket();
     ap.Read(reader);
 }
开发者ID:Nirad,项目名称:c-raft,代码行数:5,代码来源:PacketHandlers.cs

示例11: ReadEntityRelativeMove

 public static void ReadEntityRelativeMove(TestClient client, PacketReader reader)
 {
     EntityRelativeMovePacket er = new EntityRelativeMovePacket();
     er.Read(reader);
 }
开发者ID:Nirad,项目名称:c-raft,代码行数:5,代码来源:PacketHandlers.cs

示例12: ReadNewInvalidState

 public static void ReadNewInvalidState(TestClient client, PacketReader reader)
 {
     NewInvalidStatePacket ni = new NewInvalidStatePacket();
     ni.Read(reader);
 }
开发者ID:Nirad,项目名称:c-raft,代码行数:5,代码来源:PacketHandlers.cs

示例13: ReadPickupSpawn

 public static void ReadPickupSpawn(TestClient client, PacketReader reader)
 {
     SpawnItemPacket si = new SpawnItemPacket();
     si.Read(reader);
 }
开发者ID:Nirad,项目名称:c-raft,代码行数:5,代码来源:PacketHandlers.cs

示例14: ReadMultiBlockChange

 public static void ReadMultiBlockChange(TestClient client, PacketReader reader)
 {
     MultiBlockChangePacket mbc = new MultiBlockChangePacket();
     mbc.Read(reader);
 }
开发者ID:Nirad,项目名称:c-raft,代码行数:5,代码来源:PacketHandlers.cs

示例15: ReadNamedEntitySpawn

 public static void ReadNamedEntitySpawn(TestClient client, PacketReader reader)
 {
     NamedEntitySpawnPacket bc = new NamedEntitySpawnPacket();
     bc.Read(reader);
 }
开发者ID:Nirad,项目名称:c-raft,代码行数:5,代码来源:PacketHandlers.cs


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