Inheritance: IDisposable
Beispiel #1
0
 /// <summary>
 /// Constructs a new foreign device port instance
 /// </summary>
 /// <param name="options">The options to create the port with</param>
 public ForeignDevicePort(ForeignDevicePortOptions options)
 {
     this._options = options.Clone();
     this._state = State.Closed;
     this._server = null;
     this._registrationTimer = null;
     this._registrationTimeout = DateTime.MinValue;
 }
Beispiel #2
0
 /// <summary>
 /// Constructs a new foreign device port instance
 /// </summary>
 /// <param name="options">The options to create the port with</param>
 public ForeignDevicePort(ForeignDevicePortOptions options)
 {
     this._options             = options.Clone();
     this._state               = State.Closed;
     this._server              = null;
     this._registrationTimer   = null;
     this._registrationTimeout = DateTime.MinValue;
 }
Beispiel #3
0
        /// <summary>
        /// Disposes all of the resources held by an open port, in preparation
        /// for transitioning back to a closed state
        /// </summary>
        private void _disposeAll()
        {
            if (_registrationTimer != null)
            {
                _registrationTimer.Dispose();
                _registrationTimer = null;
            }

            if (_server != null)
            {
                _server.Dispose();
                _server = null;
            }
        }
Beispiel #4
0
        /// <summary>
        /// Creates the udp socket
        /// </summary>
        private void _createServer()
        {
            IPAddress ip = null;

            if (!IPAddress.TryParse(_options.LocalHost, out ip))
            {
                var localIps = Dns.GetHostAddresses(_options.LocalHost);
                if (localIps.Length == 0)
                {
                    throw new Exception("Could not resolve '" + _options.LocalHost + "'");
                }
                else
                {
                    ip = localIps[0];
                }
            }

            var localEp = new IPEndPoint(ip, _options.LocalPort);

            _server = new UDPAsyncServer(localEp, _onDatagramReceived);
        }
Beispiel #5
0
        /// <summary>
        /// Disposes all of the resources held by an open port, in preparation
        /// for transitioning back to a closed state
        /// </summary>
        private void _disposeAll()
        {
            if (_registrationTimer != null)
            {
                _registrationTimer.Dispose();
                _registrationTimer = null;
            }

            if(_server != null)
            {
                _server.Dispose();
                _server = null;
            }
        }
Beispiel #6
0
        /// <summary>
        /// Creates the udp socket
        /// </summary>
        private void _createServer()
        {
            IPAddress ip = null;
            if(!IPAddress.TryParse(_options.LocalHost, out ip))
            {
                var localIps = Dns.GetHostAddresses(_options.LocalHost);
                if (localIps.Length == 0)
                {
                    throw new Exception("Could not resolve '" + _options.LocalHost + "'");
                }
                else
                {
                    ip = localIps[0];
                }
            }

            var localEp = new IPEndPoint(ip, _options.LocalPort);
            _server = new UDPAsyncServer(localEp, _onDatagramReceived);
        }