Ejemplo n.º 1
0
        /// <summary>
        /// Dispose of the NetworkService's resources
        /// </summary>
        public void Dispose()
        {
            NamingClient.Dispose();
            _remoteManager.Dispose();

            Logger.Log(Level.Verbose, "Disposed of network service");
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Register the identifier for the NetworkService with the NameService.
        /// </summary>
        /// <param name="id">The identifier to register</param>
        public void Register(IIdentifier id)
        {
            Logger.Log(Level.Verbose, "Registering id {0} with network service.", id);

            _localIdentifier = id;
            NamingClient.Register(id.ToString(), _remoteManager.LocalEndpoint);

            Logger.Log(Level.Verbose, "End of Registering id {0} with network service.", id);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Dispose of the NetworkService's resources
        /// </summary>
        public void Dispose()
        {
            if (Interlocked.Exchange(ref _disposed, 1) == 0)
            {
                NamingClient.Dispose();
                _remoteManager.Dispose();

                LOGGER.Log(Level.Verbose, "Disposed of network service");
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Unregister the identifier for the NetworkService with the NameService.
        /// </summary>
        public void Unregister()
        {
            if (_localIdentifier == null)
            {
                throw new IllegalStateException("Cannot unregister a non existant identifier");
            }

            NamingClient.Unregister(_localIdentifier.ToString());
            _localIdentifier = null;
            _messageHandlerDisposable.Dispose();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Register the identifier for the NetworkService with the NameService.
        /// </summary>
        /// <param name="id">The identifier to register</param>
        public void Register(IIdentifier id)
        {
            LOGGER.Log(Level.Verbose, "Registering id {0} with network service.", id);

            _localIdentifier = id;
            NamingClient.Register(id.ToString(), _remoteManager.LocalEndpoint);

            // Create and register incoming message handler
            var anyEndpoint = new IPEndPoint(IPAddress.Any, 0);

            _messageHandlerDisposable = _remoteManager.RegisterObserver(anyEndpoint, _messageHandler);

            LOGGER.Log(Level.Verbose, "End of Registering id {0} with network service.", id);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Unregister the identifier for the NetworkService with the NameService.
        /// </summary>
        public void Unregister()
        {
            if (_localIdentifier == null)
            {
                throw new IllegalStateException("Cannot unregister a non existant identifier");
            }

            NamingClient.Unregister(_localIdentifier.ToString());

            _localIdentifier = null;

            if (_universalObserverDisposable != null)
            {
                _universalObserverDisposable.Dispose();
            }

            if (_remoteMessageUniversalObserver != null)
            {
                _remoteMessageUniversalObserver.Dispose();
            }
        }