public int GetNextOutgoingPacket(byte[] data, out uint netAdr, out ushort port)
 {
     //CheckIfUsable();
     netAdr = 0;
     port = 0;
     using (NativeBuffer packetBuffer = new NativeBuffer(data))
     {
         int result = NativeMethods.GameServer_GetNextOutgoingPacket(packetBuffer.UnmanagedMemory, packetBuffer.UnmanagedSize, ref netAdr, ref port);
         packetBuffer.ReadFromUnmanagedMemory(result);
         return result;
     }
 }
 public int GetGlobalStatHistory(string name, out double[] data, int historyDays)
 {
     CheckIfUsable();
     byte[] byteData = new byte[historyDays * sizeof(double)];
     using (NativeBuffer buffer = new NativeBuffer(byteData))
     {
         int result = NativeMethods.Stats_GetGlobalStatHistoryDouble(name, buffer.UnmanagedMemory,
             (uint)historyDays);
         buffer.ReadFromUnmanagedMemory(result);
         data = NativeBuffer.ToDouble(byteData);
         return result;
     }
 }
        public int GetLobbyChatEntry(SteamID steamIDLobby, int chatID, out SteamID steamIDUser, byte[] data, out ChatEntryType chatEntryType)
        {
            CheckIfUsable();
            ulong rawCreator = 0;
            int chatEntryTemp = 0;

            using (NativeBuffer buffer = new NativeBuffer(data))
            {
                int result = NativeMethods.MatchMaking_GetLobbyChatEntry(steamIDLobby.AsUInt64, chatID, ref rawCreator, buffer.UnmanagedMemory, buffer.UnmanagedSize, ref chatEntryTemp);
                buffer.ReadFromUnmanagedMemory(result);

                steamIDUser = new SteamID(rawCreator);
                chatEntryType = (ChatEntryType)chatEntryTemp;
                return result;
            }
        }
        public int UGCRead(SteamTypes.UGCHandle handle, byte[] data, uint offset, UGCReadAction action)
        {
            CheckIfUsable();

            using (NativeBuffer buffer = new NativeBuffer(data))
            {
                int bytesRead = NativeMethods.Cloud_UGCRead(handle.AsUInt64, buffer.UnmanagedMemory,
                    buffer.UnmanagedSize, offset, (int)action);
                buffer.ReadFromUnmanagedMemory(bytesRead);
                return bytesRead;
            }
        }
        public bool ReadP2PPacket(byte[] dest, out uint msgSize, out SteamID steamIDRemote, int channel = 0)
        {
            CheckIfUsable();
            msgSize = 0;

            using (NativeBuffer bufferKey = new NativeBuffer(dest))
            {
                ulong rawCreator = 0;
                bool returnvalue = NativeMethods.Networking_ReadP2PPacket(bufferKey.UnmanagedMemory,
                    (uint)bufferKey.UnmanagedSize, ref msgSize, ref rawCreator, channel);
                steamIDRemote = new SteamID(rawCreator);
                bufferKey.ReadFromUnmanagedMemory((int)msgSize);
                return returnvalue;
            }
        }
 public bool RetrieveData(NetListenSocketHandle listenSocket, byte[] dest, out uint msgSize, out NetSocketHandle socket)
 {
     CheckIfUsable();
     msgSize = 0;
     uint rawSocket = 0;
     using (NativeBuffer bufferKey = new NativeBuffer(dest))
     {
         bool result = NativeMethods.Networking_RetrieveData(listenSocket.AsUInt32,
             bufferKey.UnmanagedMemory, (uint)bufferKey.UnmanagedSize, ref msgSize, ref rawSocket);
         bufferKey.ReadFromUnmanagedMemory((int)msgSize);
         socket = new NetSocketHandle(rawSocket);
         return result;
     }
 }