Esempio n. 1
0
        /// <summary>
        /// Receive the next packet for the local user, and information associated with this packet, if it exists.
        /// </summary>
        /// <param name="options">Information about who is requesting the size of their next packet, and how much data can be stored safely</param>
        /// <param name="outPeerId">The Remote User who sent data. Only set if there was a packet to receive.</param>
        /// <param name="outSocketId">The Socket ID of the data that was sent. Only set if there was a packet to receive.</param>
        /// <param name="outChannel">The channel the data was sent on. Only set if there was a packet to receive.</param>
        /// <param name="outData">Buffer to store the data being received. Must be at least <see cref="GetNextReceivedPacketSize" /> in length or data will be truncated</param>
        /// <param name="outBytesWritten">The amount of bytes written to OutData. Only set if there was a packet to receive.</param>
        /// <returns>
        /// <see cref="Result" />::<see cref="Result.Success" /> - If the packet was received successfully
        /// <see cref="Result" />::<see cref="Result.InvalidParameters" /> - If input was invalid
        /// <see cref="Result" />::<see cref="Result.NotFound" /> - If there are no packets available for the requesting user
        /// </returns>
        public Result ReceivePacket(ReceivePacketOptions options, out ProductUserId outPeerId, out SocketId outSocketId, out byte outChannel, ref byte[] outData, out uint outBytesWritten)
        {
            var optionsInternal = Helper.CopyProperties <ReceivePacketOptionsInternal>(options);

            outPeerId = Helper.GetDefault <ProductUserId>();

            var outPeerIdAddress = IntPtr.Zero;

            outSocketId = Helper.GetDefault <SocketId>();

            var outSocketIdInternal = new SocketIdInternal();

            outChannel = Helper.GetDefault <byte>();

            outBytesWritten = Helper.GetDefault <uint>();

            var funcResult = EOS_P2P_ReceivePacket(InnerHandle, ref optionsInternal, ref outPeerIdAddress, ref outSocketIdInternal, ref outChannel, outData, ref outBytesWritten);

            Helper.TryMarshalDispose(ref optionsInternal);

            Helper.TryMarshalGet(outPeerIdAddress, out outPeerId);
            outSocketId = Helper.CopyProperties <SocketId>(outSocketIdInternal);
            Helper.TryMarshalDispose(ref outSocketIdInternal);

            var funcResultReturn = Helper.GetDefault <Result>();

            Helper.TryMarshalGet(funcResult, out funcResultReturn);
            return(funcResultReturn);
        }
Esempio n. 2
0
 private static extern Result EOS_P2P_ReceivePacket(IntPtr handle, ref ReceivePacketOptionsInternal options, ref IntPtr outPeerId, ref SocketIdInternal outSocketId, ref byte outChannel, byte[] outData, ref uint outBytesWritten);