public TcpCommunication(TcpEndpointData endpointData,
                                IMessageSerializer serializer,
                                ChannelSettings channelSettings,
                                TcpConnectionSettings connetcionSettings,
                                ISecurityWrapper securityWrapper)
        {
            Enforce.NotNull(endpointData, nameof(endpointData));
            Enforce.NotNull(serializer, nameof(serializer));
            Enforce.NotNull(channelSettings, nameof(channelSettings));
            Enforce.NotNull(connetcionSettings, nameof(connetcionSettings));

            _endpointData       = endpointData;
            _serializer         = serializer;
            _channelSettings    = channelSettings;
            _connetcionSettings = connetcionSettings;
            _securityWrapper    = securityWrapper;
        }
Beispiel #2
0
        private static IChannel <StringMessage> StartFirstInstance()
        {
            var endpointData   = new TcpEndpointData(IPAddress.Any, 2000);
            var channelAwaiter = new TcpChannelAwaiter <StringMessage>(endpointData,
                                                                       new StringMessageSerializer(),
                                                                       ChannelSettings.GetDefault(),
                                                                       GetChatConnectionSettings());

            try
            {
                channelAwaiter.Start();
                Console.WriteLine("Run another instance to begin chat");
                return((IChannel <StringMessage>)channelAwaiter.AwaitNewChannel());
            }
            catch (SocketException ex) when(ex.ErrorCode == 10048)
            {
                // someone has already got running listener on localhost:2000
                return(null);
            }
        }
 public TcpCommunication(TcpEndpointData endpointData, IMessageSerializer serializer)
     : this(endpointData, serializer, ChannelSettings.GetDefault(), TcpConnectionSettingsBuilder.GetDefaultSettings(), null)
 {
 }