Example #1
0
        private void Initialise(TypeFilterLevel typeFilterLevel, IClientChannelSinkProvider clientSinkProvider, IServerChannelSinkProvider serverSinkProvider, int port, bool listen, bool keepAlive, ulong keepAliveTime, ulong KeepAliveInterval, short maxRetries, int retryDelay, IPAddress bindToAddress)
        {
            _tcpKeepAliveEnabled  = keepAlive;
            _tcpKeepAliveTime     = keepAliveTime;
            _tcpKeepAliveInterval = KeepAliveInterval;
            _maxRetries           = maxRetries;
            _retryDelay           = retryDelay;
            _bindToAddress        = bindToAddress;

            if (clientSinkProvider == null)
            {
                clientSinkProvider = new BinaryClientFormatterSinkProvider();
            }
            if (serverSinkProvider == null)
            {
                Trace.WriteLine("Setting serialization filter: {0}", typeFilterLevel);
                BinaryServerFormatterSinkProvider tempProvider = new BinaryServerFormatterSinkProvider();
                tempProvider.TypeFilterLevel = typeFilterLevel;
                serverSinkProvider           = tempProvider;
            }

            // Initialise clientSinkProvider
            this.clientSinkProvider = clientSinkProvider;
            while (clientSinkProvider.Next != null)
            {
                clientSinkProvider = clientSinkProvider.Next;
            }
            clientSinkProvider.Next = new ClientTransportSinkProvider();

            messageSink = new ServerTransportSink(ChannelServices.CreateServerChannelSinkChain(serverSinkProvider, this));
            serverSinkProvider.GetChannelData(channelData);

            if (listen)
            {
                StartListening(port);
            }

            channelData = new TcpExChannelData(this);

            Manager.BeginReadMessage(_channelID, null, new AsyncCallback(messageSink.ReceiveMessage), _channelID);
        }
Example #2
0
        private void Initialise(TypeFilterLevel typeFilterLevel, IClientChannelSinkProvider clientSinkProvider, IServerChannelSinkProvider serverSinkProvider, int port, bool listen, bool keepAlive, ulong keepAliveTime, ulong KeepAliveInterval, short maxRetries, int retryDelay, IPAddress bindToAddress)
        {
            _tcpKeepAliveEnabled = keepAlive;
            _tcpKeepAliveTime = keepAliveTime;
            _tcpKeepAliveInterval = KeepAliveInterval;
            _maxRetries = maxRetries;
            _retryDelay = retryDelay;
            _bindToAddress = bindToAddress;

            if (clientSinkProvider == null)
                clientSinkProvider = new BinaryClientFormatterSinkProvider();
            if (serverSinkProvider == null)
            {
                Trace.WriteLine("Setting serialization filter: {0}", typeFilterLevel);
                BinaryServerFormatterSinkProvider tempProvider = new BinaryServerFormatterSinkProvider();
                tempProvider.TypeFilterLevel = typeFilterLevel;
                serverSinkProvider = tempProvider;
            }

            // Initialise clientSinkProvider
            this.clientSinkProvider = clientSinkProvider;
            while (clientSinkProvider.Next != null)
                clientSinkProvider = clientSinkProvider.Next;
            clientSinkProvider.Next = new ClientTransportSinkProvider();

            messageSink = new ServerTransportSink(ChannelServices.CreateServerChannelSinkChain(serverSinkProvider, this));
            serverSinkProvider.GetChannelData(channelData);

            if (listen)
            {
                StartListening(port);
            }

            channelData = new TcpExChannelData(this);

            Manager.BeginReadMessage(_channelID, null, new AsyncCallback(messageSink.ReceiveMessage), _channelID);
        }