private void _SendUnconnectedRPC(UnconnectedMessage msg, NetworkEndPoint target)
        {
            _MasterStart();

            Log.Debug(NetworkLogFlags.RPC, "Sending unconnected RPC ", msg.internCode, " to ", target);

            _master.SendOutOfBandMessage(msg.stream._buffer, target);
        }
        public void RequestKnownHostData(NetworkEndPoint target)
        {
            if (!_knownHosts.ContainsKey(target))
            {
                _knownHosts.Add(target, new HostData(target));
            }

            var msg = new UnconnectedMessage(UnconnectedMessage.InternalCode.KnownHostRequest);

            msg.stream.WriteDouble(NetworkTime.localTime);
            msg.stream.WriteBoolean(false);
            _SendUnconnectedRPC(msg, target);
        }
        public void DiscoverLocalHosts(HostDataFilter filter, int remoteStartPort, int remoteEndPort)
        {
            if (remoteEndPort - remoteStartPort >= 20)
            {
                Log.Warning(NetworkLogFlags.MasterServer, "Sending broadcast packets on more than 20 ports (with frequent interval) to discover local hosts, may cause some routers to block UDP traffic or behave undesirably.");
            }

            _timeOfDiscoveryRequest = NetworkTime.localTime;

            for (int port = remoteStartPort; port <= remoteEndPort; port++)
            {
                var msg = new UnconnectedMessage(UnconnectedMessage.InternalCode.DiscoverHostRequest);
                msg.stream.WriteHostDataFilter(filter);
                msg.stream.WriteDouble(NetworkTime.localTime);

                var broadcast = new NetworkEndPoint(IPAddress.Broadcast, port);
                _SendUnconnectedRPC(msg, broadcast);
            }
        }