Exemplo n.º 1
0
 private bool IsP2PPacketAvailable(bool isServer, out uint size)
 {
     if (isServer)
     {
         return(SteamGameServerNetworking.IsP2PPacketAvailable(out size, 0));
     }
     return(SteamNetworking.IsP2PPacketAvailable(out size, 0));
 }
Exemplo n.º 2
0
        void ReceiveNetworkData()
        {
            byte[]   recvBuf;
            uint     msgSize;
            CSteamID steamIDRemote;

            // Read through all packets on the steam network
            while (SteamGameServerNetworking.IsP2PPacketAvailable(out msgSize))
            {
                // Allocate room for the packet
                recvBuf = new byte[msgSize];

                // Read the packet
                if (!SteamGameServerNetworking.ReadP2PPacket(recvBuf, msgSize, out msgSize, out steamIDRemote))
                {
                    // Returns false if no data is available, done reading messages if somehow while statement doesn't catch it
                    break;
                }

                Message msg = (Message)Converter.ByteArrayToObject(recvBuf);

                switch (msg.GetMessageType())
                {
                case EMessage.EMsg_ClientInitiateConnection:
                    break;

                case EMessage.EMsg_ClientBeginAuthentication:
                    break;

                case EMessage.EMsg_ClientSendLocalUpdate:
                    break;

                case EMessage.EMsg_ClientPing:
                    break;

                case EMessage.EMsg_ClientLeavingServer:
                    break;

                default:
                    Console.WriteLine("Got an invalid message on server. MessageType: " + msg.GetMessageType());
                    break;
                }
            }
        }
        // Token: 0x06001836 RID: 6198 RVA: 0x000890D4 File Offset: 0x000874D4
        public bool read(out ICommunityEntity entity, byte[] data, out ulong length, int channel)
        {
            entity = SteamworksCommunityEntity.INVALID;
            length = 0UL;
            uint num;

            if (!SteamGameServerNetworking.IsP2PPacketAvailable(out num, channel) || (ulong)num > (ulong)((long)data.Length))
            {
                return(false);
            }
            CSteamID newSteamID;

            if (!SteamGameServerNetworking.ReadP2PPacket(data, num, out num, out newSteamID, channel))
            {
                return(false);
            }
            entity = new SteamworksCommunityEntity(newSteamID);
            length = (ulong)num;
            return(true);
        }
Exemplo n.º 4
0
        public override bool Read(out Identity user, byte[] data, out ulong length, int channel)
        {
            uint num;

            user = null;
            CSteamID id;

            length = 0L;
            if (!SteamGameServerNetworking.IsP2PPacketAvailable(out num, channel) || (num > data.Length))
            {
                return(false);
            }
            if (!SteamGameServerNetworking.ReadP2PPacket(data, num, out num, out id, channel))
            {
                LogUtils.Debug("P2P Packet reading failed on channel " + channel);
                return(false);
            }
            user   = (SteamIdentity)id;
            length = num;
            return(true);
        }