Ejemplo n.º 1
0
        public NetworkClient(RhmsCollectingServer server, NetworkConnectionManager connectionManager)
        {
            _connectionManager = connectionManager;
            _collectingServer  = server;
            _peerControlHost   = _collectingServer.GetSettings().PeerSignalServer.Host;
            _apiAccessKey      = _collectingServer.GetSettings().ApiAccessKey;

            var sourceBindAddress = _collectingServer.GetSettings().BindAddress;

            if (!IPAddress.TryParse(sourceBindAddress, out var bindIpAddress))
            {
                bindIpAddress = IPAddress.Parse(RhmsSettings.Default.BindAddress);
                Logger.Warn($"Invalid IP address specified in settings '{sourceBindAddress}', using default '{bindIpAddress}'");
            }

            _bindEp             = new IPEndPoint(bindIpAddress, 0);
            _socket             = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
            _socket.SendTimeout = _socket.ReceiveTimeout = _collectingServer.GetSettings().PeerSignalServer.SocketTimeoutMs;
            _socket.Bind(_bindEp);

            if (_peerControlHost.EndsWith("/"))
            {
                _peerControlHost = _peerControlHost.Substring(0, _peerControlHost.Length - 1);
            }

            _natUpnpCreateLocker = new object();
            NetworkRemoteControl.ClientInstance = this;
            PacketHandler = new NetPacketHandler(server, connectionManager, this);
        }
Ejemplo n.º 2
0
 public NetPacketHandler(RhmsCollectingServer server, NetworkConnectionManager connectionManager, NetworkClient netClient) {
     _collectingServer = server;
 }