// Token: 0x060020F4 RID: 8436 RVA: 0x0008E530 File Offset: 0x0008C730 public override bool TransportSend(byte[] bytes, int numBytes, int channelId, out byte error) { if (this.ignore) { error = 0; return(true); } this.logNetworkMessages = SteamNetworkConnection.cvNetP2PLogMessages.value; Client instance = Client.Instance; if (this.steamId.value == instance.SteamId) { this.TransportReceive(bytes, numBytes, channelId); error = 0; if (SteamNetworkConnection.cvNetP2PDebugTransport.value) { Debug.LogFormat("SteamNetworkConnection.TransportSend steamId=self numBytes={1} channelId={2}", new object[] { numBytes, channelId }); } return(true); } Networking.SendType eP2PSendType = Networking.SendType.Reliable; QosType qos = GameNetworkManager.singleton.connectionConfig.Channels[channelId].QOS; if (qos == QosType.Unreliable || qos == QosType.UnreliableFragmented || qos == QosType.UnreliableSequenced) { eP2PSendType = Networking.SendType.Unreliable; } if (instance.Networking.SendP2PPacket(this.steamId.value, bytes, numBytes, eP2PSendType, 0)) { error = 0; if (SteamNetworkConnection.cvNetP2PDebugTransport.value) { Debug.LogFormat("SteamNetworkConnection.TransportSend steamId={0} numBytes={1} channelId={2} error={3}", new object[] { this.steamId.value, numBytes, channelId, error }); } return(true); } error = 1; if (SteamNetworkConnection.cvNetP2PDebugTransport.value) { Debug.LogFormat("SteamNetworkConnection.TransportSend steamId={0} numBytes={1} channelId={2} error={3}", new object[] { this.steamId.value, numBytes, channelId, error }); } return(false); }
//wrapper public bool SendP2PData(ulong steamID, byte[] data, int length, Networking.SendType sendType = Networking.SendType.Reliable, int channel = 0) { if (connections.ContainsKey(steamID)) { connections[steamID].timeSinceLastMsg = 0f; } //otherwise we just haven't established the connection yet (as this must be a connect request message) return(Client.Instance.Networking.SendP2PPacket(steamID, data, data.Length, sendType, channel)); }
/// <summary> /// Send message to all players in lobby. /// </summary> /// <param name="message">Message to send</param> /// <param name="specificuser">If you want to send this to a specific user. Enter its steamid.</param> public void Send_Message(SNetMessage message, ulong specificuser = 0, Networking.SendType type = Networking.SendType.Unreliable, int channel = 0) { if (Client.Instance == null || !Client.Instance.Lobby.IsValid) { return; } string json = SNetMessage.GetMessage(message); byte[] data = Encoding.UTF8.GetBytes(json); ulong[] members = Client.Instance.Lobby.GetMemberIDs(); if (specificuser != 0) { members = new ulong[1] { specificuser } } ; int membersLength = members.Length; bool validationRequired = false; if (message.n != "Auth_H") { validationRequired = true; } data = CLZF2.Compress(data); for (int i = 0; i < membersLength; i++) { if (!SNet_Auth.current.validatedIds.Contains(members[i]) && validationRequired) { continue; // Skip this user. Hes not validated. } Client.Instance.Networking.SendP2PPacket(members[i], data, data.Length, type, channel); } } }