Example #1
0
        /// <summary>
        /// Constructs a DefaultRemoteManager listening on the specified address and any
        /// available port.
        /// </summary>
        /// <param name="localAddress">The address to listen on</param>
        /// <param name="port">The port to listen on</param>
        /// <param name="codec">The codec used for serializing messages</param>
        public DefaultRemoteManager(IPAddress localAddress, int port, ICodec <T> codec)
        {
            if (localAddress == null)
            {
                throw new ArgumentNullException("localAddress");
            }
            if (port < 0)
            {
                throw new ArgumentException("Listening port must be greater than or equal to zero");
            }
            if (codec == null)
            {
                throw new ArgumentNullException("codec");
            }

            _observerContainer = new ObserverContainer <T>();
            _codec             = new RemoteEventCodec <T>(codec);
            _cachedClients     = new Dictionary <IPEndPoint, ProxyObserver>();

            IPEndPoint localEndpoint = new IPEndPoint(localAddress, port);

            // Begin to listen for incoming messages
            _server = new TransportServer <IRemoteEvent <T> >(localEndpoint, _observerContainer, _codec);
            _server.Run();

            LocalEndpoint = _server.LocalEndpoint;
            Identifier    = new SocketRemoteIdentifier(LocalEndpoint);
        }
Example #2
0
        /// <summary>
        /// Constructs a DefaultRemoteManager. Does not listen for incoming messages.
        /// </summary>
        /// <param name="codec">The codec used for serializing messages</param>
        public DefaultRemoteManager(ICodec <T> codec)
        {
            using (LOGGER.LogFunction("DefaultRemoteManager::DefaultRemoteManager"))
            {
                if (codec == null)
                {
                    throw new ArgumentNullException("codec");
                }

                _observerContainer = new ObserverContainer <T>();
                _codec             = new RemoteEventCodec <T>(codec);
                _cachedClients     = new Dictionary <IPEndPoint, ProxyObserver>();

                LocalEndpoint = new IPEndPoint(NetworkUtils.LocalIPAddress, 0);
                Identifier    = new SocketRemoteIdentifier(LocalEndpoint);
            }
        }