Ejemplo n.º 1
0
        public static void PacketCollectionThread()
        {
            uint     packetSize;
            uint     readBytes;
            CSteamID remoteID;

            byte[] data;

            while (SteamNetworking.IsP2PPacketAvailable(out packetSize))
            {
                data = new byte[packetSize];
                if (SteamNetworking.ReadP2PPacket(data, packetSize, out readBytes, out remoteID))
                {
                    CustomPacket newPacket = ParseCustomPacket(data);

                    if (newPacket != null)
                    {
                        if (newPacket.PACKETID >= GlobalPacketID && !newPacket.ignorePacketID)
                        {
                            PacketsReady.Add(newPacket);
                            GlobalPacketID = newPacket.PACKETID + 1;
                        }
                        else
                        {
                            //Junk packet
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public static void RunReadyPackets()
        {
            while (PacketsReady.Count > 0)
            {
                CustomPacket p = PacketsReady[0];
                PacketsReady.RemoveAt(0);

                MethodInfo method;
                if (allRPCs.TryGetValue(p.RPCId, out method))
                {
                    ReflectionHelper.InvokeMethod(method, null, p.data);
                }
            }
        }