Example #1
0
        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);
        }
Example #2
0
        /// <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);
        }
Example #3
0
        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);
        }
Example #4
0
        /// <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;
        }