public bool Update()
        {
            var receivedMessages = new IntPtr[_steamOptions.MaxMessagesPolling];
            int receivedCount;

            if ((receivedCount = SteamNetworkingSockets.ReceiveMessagesOnPollGroup(_pollGroup, receivedMessages,
                                                                                   _steamOptions.MaxMessagesPolling)) > 0)
            {
                for (int i = 0; i < receivedCount; i++)
                {
                    SteamNetworkingMessage_t steamMessage = SteamNetworkingMessage_t.FromIntPtr(receivedMessages[i]);

                    var message = new Message
                    {
                        Data     = new byte[steamMessage.m_cbSize],
                        Endpoint = FindKeyByValue(SteamConnections, steamMessage.m_conn)
                    };

                    Marshal.Copy(steamMessage.m_pData, message.Data, 0, steamMessage.m_cbSize);

                    BufferQueue.Enqueue(message);

                    if (_steamOptions.EnableDebug)
                    {
                        LogDebug(
                            $"Steam back-end queuing up messages to buffer. Current Message queue: {BufferQueue.Count}");
                    }

                    SteamNetworkingMessage_t.Release(receivedMessages[i]);
                }
            }

            return(BufferQueue.Count > 0);
        }
Exemplo n.º 2
0
        protected (byte[], int) ProcessMessage(IntPtr ptrs)
        {
            SteamNetworkingMessage_t data = Marshal.PtrToStructure <SteamNetworkingMessage_t>(ptrs);

            byte[] managedArray = new byte[data.m_cbSize];
            Marshal.Copy(data.m_pData, managedArray, 0, data.m_cbSize);
            SteamNetworkingMessage_t.Release(ptrs);

            int channel = managedArray[managedArray.Length - 1];

            Array.Resize(ref managedArray, managedArray.Length - 1);
            return(managedArray, channel);
        }
Exemplo n.º 3
0
 // Token: 0x06000992 RID: 2450 RVA: 0x00046288 File Offset: 0x00044488
 public ZPackage Recv()
 {
     if (!this.IsConnected())
     {
         return(null);
     }
     IntPtr[] array = new IntPtr[1];
     if (SteamNetworkingSockets.ReceiveMessagesOnConnection(this.m_con, array, 1) == 1)
     {
         SteamNetworkingMessage_t steamNetworkingMessage_t = Marshal.PtrToStructure <SteamNetworkingMessage_t>(array[0]);
         byte[] array2 = new byte[steamNetworkingMessage_t.m_cbSize];
         Marshal.Copy(steamNetworkingMessage_t.m_pData, array2, 0, steamNetworkingMessage_t.m_cbSize);
         ZPackage zpackage = new ZPackage(array2);
         steamNetworkingMessage_t.m_pfnRelease = array[0];
         steamNetworkingMessage_t.Release();
         this.m_totalRecv += zpackage.Size();
         this.m_gotData    = true;
         return(zpackage);
     }
     return(null);
 }