public void Start() { var message = new Message.Message(); if (!_udpManuallySet) { // not set, decide based on the data if (DataMap == null) { SetIsUdp(true); } else { SetIsUdp(false); message.SetDataMap(new DataMap(DataMap)); } } message.SetKey(MessageKey); message.SetIntValue(0); message.SetIsUdp(IsUdp); _peer.BroadcastRpc.BroadcastHandler.Receive(message); }
/// <summary> /// This method makes a copy of the original message and prepares it for /// sending it to the relay. /// </summary> /// <param name="message"></param> /// <returns></returns> private static Message.Message CreateRconMessage(Message.Message message) { // get relay address from the unreachable peer var relayAddresses = message.Recipient.PeerSocketAddresses.ToArray(); PeerSocketAddress socketAddress; if (relayAddresses.Length > 0) { // we should be fair and choose one of the relays randomly socketAddress = relayAddresses[Utils.Utils.RandomPositiveInt(relayAddresses.Length)]; } else { throw new ArgumentException("There are no PeerSocketAddresses available for this relayed peer. This should not be possible!"); } // we need to make a copy of the original message var rconMessage = new Message.Message(); rconMessage.SetSender(message.Sender); rconMessage.SetVersion(message.Version); rconMessage.SetIntValue(message.MessageId); // make the message ready to send PeerAddress recipient = message.Recipient .ChangeAddress(socketAddress.InetAddress) .ChangePorts(socketAddress.TcpPort, socketAddress.UdpPort) .ChangeIsRelayed(false); rconMessage.SetRecipient(recipient); rconMessage.SetCommand(Rpc.Rpc.Commands.Rcon.GetNr()); rconMessage.SetType(Message.Message.MessageType.Request1); return(rconMessage); }
/// <summary> /// This method makes a copy of the original message and prepares it for /// sending it to the relay. /// </summary> /// <param name="message"></param> /// <returns></returns> private static Message.Message CreateRconMessage(Message.Message message) { // get relay address from the unreachable peer var relayAddresses = message.Recipient.PeerSocketAddresses.ToArray(); PeerSocketAddress socketAddress; if (relayAddresses.Length > 0) { // we should be fair and choose one of the relays randomly socketAddress = relayAddresses[Utils.Utils.RandomPositiveInt(relayAddresses.Length)]; } else { throw new ArgumentException("There are no PeerSocketAddresses available for this relayed peer. This should not be possible!"); } // we need to make a copy of the original message var rconMessage = new Message.Message(); rconMessage.SetSender(message.Sender); rconMessage.SetVersion(message.Version); rconMessage.SetIntValue(message.MessageId); // make the message ready to send PeerAddress recipient = message.Recipient .ChangeAddress(socketAddress.InetAddress) .ChangePorts(socketAddress.TcpPort, socketAddress.UdpPort) .ChangeIsRelayed(false); rconMessage.SetRecipient(recipient); rconMessage.SetCommand(Rpc.Rpc.Commands.Rcon.GetNr()); rconMessage.SetType(Message.Message.MessageType.Request1); return rconMessage; }