Esempio n. 1
0
        public IConnection NewConnection(INode localEndpoint, INode remoteEndpoint)
        {
            var connection = CreateConnection(localEndpoint, remoteEndpoint);

            connection.Configure(Config);

            if (ReceivedData != null)
            {
                connection.Receive += (ReceivedDataCallback)ReceivedData.Clone();
            }
            if (ConnectionEstablishedCallback != null)
            {
                connection.OnConnection += (ConnectionEstablishedCallback)ConnectionEstablishedCallback.Clone();
            }
            if (ConnectionTerminatedCallback != null)
            {
                connection.OnDisconnection += (ConnectionTerminatedCallback)ConnectionTerminatedCallback.Clone();
            }
            if (ExceptionCallback != null)
            {
                connection.OnError += (ExceptionCallback)ExceptionCallback.Clone();
            }

            return(connection);
        }
Esempio n. 2
0
        public IReactor NewReactor(INode listenAddress)
        {
            var reactor = NewReactorInternal(listenAddress);

            reactor.Configure(Config);

            if (ReceivedData != null)
            {
                reactor.OnReceive += (ReceivedDataCallback)ReceivedData.Clone();
            }
            if (ConnectionEstablishedCallback != null)
            {
                reactor.OnConnection += (ConnectionEstablishedCallback)ConnectionEstablishedCallback.Clone();
            }
            if (ConnectionTerminatedCallback != null)
            {
                reactor.OnDisconnection += (ConnectionTerminatedCallback)ConnectionTerminatedCallback.Clone();
            }
            if (ExceptionCallback != null)
            {
                reactor.OnError += (ExceptionCallback)ExceptionCallback.Clone();
            }

            return(reactor);
        }