Example #1
0
        public override void Send(ulong clientId, ArraySegment <byte> data, string channelName)
        {
            if (!channelNameToId.ContainsKey(channelName))
            {
                if (NetworkLog.CurrentLogLevel <= LogLevel.Error)
                {
                    NetworkLog.LogError("SteamP2PTransport - Can't Send to client, channel with channelName: " + channelName + " is not present");
                }
                return;
            }

            int     channelId = channelNameToId[channelName];
            P2PSend sendType  = channelSendTypes[channelId];

            if (clientId == ServerClientId)
            {
                SteamNetworking.SendP2PPacket(serverUser.SteamId, data.Array, data.Count, channelId, sendType);
            }
            else
            {
                if (connectedUsers.ContainsKey(clientId))
                {
                    SteamNetworking.SendP2PPacket(connectedUsers[clientId].SteamId, data.Array, data.Count, channelId, sendType);
                }
                else
                {
                    if (NetworkLog.CurrentLogLevel <= LogLevel.Error)
                    {
                        NetworkLog.LogError("SteamP2PTransport - Can't Send to client, client not connected, clientId: " + clientId);
                    }
                }
            }
        }
Example #2
0
        private int AddChannel(ChannelType type)
        {
            P2PSend options = P2PSend.ReliableWithBuffering;

            switch (type)
            {
            case ChannelType.Unreliable:
                options = P2PSend.Unreliable;
                break;

            case ChannelType.UnreliableSequenced:
                options = P2PSend.Unreliable;
                break;

            case ChannelType.Reliable:
                options = P2PSend.ReliableWithBuffering;
                break;

            case ChannelType.ReliableSequenced:
                options = P2PSend.ReliableWithBuffering;
                break;

            case ChannelType.ReliableFragmentedSequenced:
                options = P2PSend.ReliableWithBuffering;
                break;

            default:
                options = P2PSend.ReliableWithBuffering;
                break;
            }
            channelSendTypes.Add(channelCounter, options);
            channelCounter++;
            return(channelCounter - 1);
        }
Example #3
0
        private void SendToId(INetworkMessage msg, P2PSend send, SteamId id)
        {
            P2PMessage pMsg = msg.MakeMsg();

            byte[] bytes = pMsg.GetBytes();
            SteamNetworking.SendP2PPacket(id, bytes, bytes.Length, 0, send);
        }
        /// <summary>
        /// Actually sends the packet using SteamNetworking
        /// </summary>
        /// <param name="dgram">byte[] to send</param>
        /// <param name="bytes">number of bytes in the packet</param>
        /// <param name="steamId">SteamId of the recipient</param>
        /// <param name="type">Steamworks.P2PSend type</param>
        /// <returns></returns>
        int DoSend(byte[] dgram, int bytes, SteamId steamId, P2PSend type)
        {
            if (SteamNetworking.SendP2PPacket(steamId, dgram, bytes, 0, type) == false)
            {
                Logging.BMSLog.LogWarningFormat("CachedSteamP2PClient:DoSend() WARNING: Unable to send packet to {0}", steamId.Value);
            }

            return(0);
        }
Example #5
0
        /// <summary>
        /// Prepare & send packet to SteamId
        /// </summary>
        /// <param name="dgram">byte[] to send</param>
        /// <param name="bytes">number of bytes in the packet</param>
        /// <param name="steamId">SteamId of the recipient</param>
        /// <param name="type">Steamworks.P2PSend type</param>
        /// <returns></returns>
        public int Send(byte[] dgram, int bytes, SteamId steamId, P2PSend type = P2PSend.Unreliable)
        {
            CheckDisposed();
            if (dgram == null)
            {
                throw new ArgumentNullException("dgram is null");
            }

            return(DoSend(dgram, bytes, steamId, type));
        }
Example #6
0
        private void ServerSendToAll(INetworkMessage msg, P2PSend send)
        {
            P2PMessage pMsg = msg.MakeMsg();

            byte[] bytes = pMsg.GetBytes();
            foreach (SteamId p in players)
            {
                SteamNetworking.SendP2PPacket(p, bytes, bytes.Length, 0, send);
            }
        }
Example #7
0
        /// <summary>
        /// Actually sends the packet using SteamNetworking
        /// </summary>
        /// <param name="dgram">byte[] to send</param>
        /// <param name="bytes">number of bytes in the packet</param>
        /// <param name="steamId">SteamId of the recipient</param>
        /// <param name="type">Steamworks.P2PSend type</param>
        /// <returns></returns>
        int DoSend(byte[] dgram, int bytes, SteamId steamId, P2PSend type)
        {
            // TODO:  Option to set up multi-channel comms. Using 0 as the default and only channel for now

            if (SteamNetworking.SendP2PPacket(steamId, dgram, bytes, 0, type) == false)
            {
                Logging.BMSLog.LogWarningFormat("CachedSteamP2PClient:DoSend() WARNING: Unable to send packet to {0}", steamId.Value);
            }

            return(0);
        }
Example #8
0
 protected void Send(SteamId host, byte[] msgBuffer, P2PSend sendType, int channel)
 {
     if (!Steamworks.SteamClient.IsValid)
     {
         throw new ObjectDisposedException("Steamworks");
     }
     if (channel >= channels.Length)
     {
         channel = 0;
     }
     SteamNetworking.SendP2PPacket(host, msgBuffer, msgBuffer.Length, channel, sendType);
 }
        /// <summary>
        /// Actually sends the packet using SteamNetworking
        /// </summary>
        /// <param name="dgram">byte[] to send</param>
        /// <param name="bytes">number of bytes in the packet</param>
        /// <param name="steamId">SteamId of the recipient</param>
        /// <param name="type">Steamworks.P2PSend type</param>
        /// <returns></returns>
        int DoSend(byte[] dgram, int bytes, SteamId steamId, P2PSend type)
        {
            if (SteamNetworking.SendP2PPacket(steamId, dgram, bytes, 0, type) == false)
            {
                Logging.BMSLog.LogWarningFormat("CachedSteamP2PClient:DoSend() WARNING: Unable to send packet to {0}", steamId.Value);
            }
            //else
            //{
            //	Logging.BMSLog.Log("packet sent to " + steamId.Value.ToString() + ". Length = " + bytes);
            //}

            return(0);
        }
Example #10
0
        public uint GetMaxPacketSize(P2PSend sendType)
        {
            switch (sendType)
            {
            case P2PSend.Unreliable:
            case P2PSend.UnreliableNoDelay:
                return(1200);    //UDP like - MTU size.

            case P2PSend.Reliable:
            case P2PSend.ReliableWithBuffering:
                return(maxPacketSize);    //Reliable message send. Can send up to 1MB of data in a single message.

            default:
                Debug.LogError("Unknown type so uknown max size");
                return(0);
            }
        }
        /// <summary>
        /// Sends a packet via Steamworks; Returns whether or not the packed could be sent
        /// </summary>
        public bool SendPacket(SteamId id, byte[] data, int len = -1, P2PChannel channel = P2PChannel.RELIABLE)
        {
            if (len > MP_PACKET_MAX || data.Length > MP_PACKET_MAX)
            {
                Output.LogWarning($"{Name}: Attempted to send a packet which exceeded MP_MAX_SIZE!");
                return(false);
            }

            if (channel < 0 || channel >= P2PChannel.NUM_CHANNELS)
            {
                Output.LogWarning($"{Name}: Invalid send channel specified, defaulting to Reliable");
                return(SteamNetworking.SendP2PPacket(id, data, len, (int)P2PChannel.RELIABLE, P2PSend.Reliable));
            }

            // Cast channel to send type
            P2PSend send = (P2PSend)channel;

            return(SteamNetworking.SendP2PPacket(id, data, len, (int)channel, send));
        }
Example #12
0
        public bool SendP2PPacket(SteamId steamIDRemote, IntPtr pubData, uint cubData, P2PSend eP2PSendType, int nChannel)
        {
            var returnValue = _SendP2PPacket(Self, steamIDRemote, pubData, cubData, eP2PSendType, nChannel);

            return(returnValue);
        }
Example #13
0
 public static extern bool _SendP2PPacket(IntPtr self, SteamId steamIDRemote, IntPtr pubData, uint cubData, P2PSend eP2PSendType, int nChannel);
 internal bool SendP2PPacket(SteamId steamIDRemote, IntPtr pubData, uint cubData, P2PSend eP2PSendType, int nChannel)
 {
     return(_SendP2PPacket(Self, steamIDRemote, pubData, cubData, eP2PSendType, nChannel));
 }
        internal bool SendP2PPacket(SteamId steamIDRemote, IntPtr pubData, uint cubData, P2PSend eP2PSendType, int nChannel)
        {
            bool self = this._SendP2PPacket(this.Self, steamIDRemote, pubData, cubData, eP2PSendType, nChannel);

            return(self);
        }
Example #16
0
 public static unsafe bool SendP2PPacket(SteamId steamid, byte[] data, int length = -1, int nChannel = 0, P2PSend sendType = 2)
 {
     //
     // Current member / type: System.Boolean Steamworks.SteamNetworking::SendP2PPacket(Steamworks.SteamId,System.Byte[],System.Int32,System.Int32,Steamworks.P2PSend)
     // File path: D:\GameServers\Rust\RustDedicated_Data\Managed\Facepunch.Steamworks.dll
     //
     // Product version: 2019.1.118.0
     // Exception in: System.Boolean SendP2PPacket(Steamworks.SteamId,System.Byte[],System.Int32,System.Int32,Steamworks.P2PSend)
     //
     // Specified argument was out of the range of valid values.
     // Parameter name: Target of array indexer expression is not an array.
     //    at ™..’() in C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Ast\Expressions\ArrayIndexerExpression.cs:line 129
     //    at ™..() in C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Ast\Expressions\UnaryExpression.cs:line 109
     //    at ™..’() in C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Ast\Expressions\UnaryExpression.cs:line 95
     //    at Telerik.JustDecompiler.Decompiler.ExpressionDecompilerStep.‹() in C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Decompiler\ExpressionDecompilerStep.cs:line 143
     //    at Telerik.JustDecompiler.Decompiler.ExpressionDecompilerStep.œ(DecompilationContext Ž, •Ÿ €–) in C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Decompiler\ExpressionDecompilerStep.cs:line 73
     //    at ‚–.™“.(MethodBody €–, •Ÿ Ÿ, ILanguage ) in C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Decompiler\DecompilationPipeline.cs:line 88
     //    at ‚–.™“.‹(MethodBody €–, ILanguage ) in C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Decompiler\DecompilationPipeline.cs:line 70
     //    at Telerik.JustDecompiler.Decompiler.Extensions.›“(™“ œ“, ILanguage , MethodBody €–, DecompilationContext& ™) in C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Decompiler\Extensions.cs:line 95
     //    at Telerik.JustDecompiler.Decompiler.Extensions.š“(MethodBody €–, ILanguage , DecompilationContext& ™,  œ–) in C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Decompiler\Extensions.cs:line 58
     //    at ——.ƒ˜.—(ILanguage , MethodDefinition €,  œ–) in C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Decompiler\WriterContextServices\BaseWriterContextService.cs:line 117
     //
     // mailto: [email protected]
 }
 /// <summary>
 /// Sends a P2P packet to the specified user.
 /// This is a session-less API which automatically establishes NAT-traversing or Steam relay server connections.
 /// NOTE: The first packet send may be delayed as the NAT-traversal code runs.
 /// </summary>
 public static unsafe bool SendP2PPacket(SteamId steamid, byte *data, uint length, int nChannel = 1, P2PSend sendType = P2PSend.Reliable)
 {
     return(Internal.SendP2PPacket(steamid, (IntPtr)data, (uint)length, (P2PSend)sendType, nChannel));
 }
Example #18
0
        public bool SendP2PPacket(SteamID steamIDRemote, IntPtr data, uint dataSize, uint dataOffset, P2PSend p2pSendType, int channel = 0)
        {
            CheckIfUsable();

            return(NativeMethods.Networking_SendP2PPacketOffset(steamIDRemote.AsUInt64, data, dataSize, dataOffset, (int)p2pSendType, channel));
        }
 // bool
 public bool SendP2PPacket(CSteamID steamIDRemote /*class CSteamID*/, IntPtr pubData /*const void **/, uint cubData /*uint32*/, P2PSend eP2PSendType /*EP2PSend*/, int nChannel /*int*/)
 {
     return(platform.ISteamNetworking_SendP2PPacket(steamIDRemote.Value, (IntPtr)pubData, cubData, eP2PSendType, nChannel));
 }
        public bool SendP2PPacket(SteamID steamIDRemote, IntPtr data, uint dataSize, uint dataOffset, P2PSend p2pSendType, int channel = 0)
        {
            CheckIfUsable();

            return NativeMethods.Networking_SendP2PPacketOffset(steamIDRemote.AsUInt64, data, dataSize, dataOffset, (int)p2pSendType, channel);
        }
        /// <summary>
        /// Sends a P2P packet to the specified user.
        /// This is a session-less API which automatically establishes NAT-traversing or Steam relay server connections.
        /// NOTE: The first packet send may be delayed as the NAT-traversal code runs.
        /// </summary>
        public static unsafe bool SendP2PPacket(SteamId steamid, byte[] data, int length = -1, int nChannel = 0, P2PSend sendType = P2PSend.Reliable)
        {
            if (length <= 0)
                length = data.Length;

            fixed(byte *p = data)
            {
                return(Internal.SendP2PPacket(steamid, (IntPtr)p, (uint)length, (P2PSend)sendType, nChannel));
            }
        }
Example #22
0
 public void SendToServer(P2PMessage msg, P2PSend send)
 {
     byte[] msgBytes = msg.GetBytes();
     SteamNetworking.SendP2PPacket(ServerId, msgBytes, msgBytes.Length, 0, send);
 }