public Communicator()
 {
     ChannelFactory = new ChannelFactory()
     {
         CreateObserverRegistry = () => ObserverRegistry,
         ChannelRouter = OnChannelRouting
     };
     Channels = new List<IChannel>();
     ObserverRegistry = new ObserverRegistry();
 }
        public static Client.IChannel CreateClientChannel(string name, string address, XunitOutputLogger.Source outputSource)
        {
            // create channel and start it

            var logger = new XunitOutputLogger($"ClientChannel({name})", outputSource);

            var factory = new Client.ChannelFactory
            {
                CreateChannelLogger = () => logger,
                CreateObserverRegistry = () => new ObserverRegistry(),
                PacketSerializer = s_clientSerializer
            };

            var udpConfig = ((NetPeerConfiguration)factory.UdpConfig);
            udpConfig.MaximumHandshakeAttempts = 1; // to fail faster

            return factory.Create(address);
        }
        public static Client.IChannel CreateClientChannel(string name, string address, XunitOutputLogger.Source outputSource)
        {
            // create channel and start it

            var logger = new XunitOutputLogger($"ClientChannel({name})", outputSource);

            var factory = new Client.ChannelFactory
            {
                CreateChannelLogger    = () => logger,
                CreateObserverRegistry = () => new ObserverRegistry(),
                PacketSerializer       = s_clientSerializer
            };

            var udpConfig = ((NetPeerConfiguration)factory.UdpConfig);

            udpConfig.MaximumHandshakeAttempts = 1; // to fail faster

            return(factory.Create(address));
        }
Ejemplo n.º 4
0
        private static void Main(string[] args)
        {
            var channelFactory = new ChannelFactory
            {
                Type = ChannelType.Tcp,
                ConnectEndPoint = new IPEndPoint(IPAddress.Loopback, 5001),
                CreateChannelLogger = () => null,
                CreateObserverRegistry = () => new ObserverRegistry(),
                PacketSerializer = PacketSerializer.CreatePacketSerializer()
            };

            // TCP
            var driver = new TestDriver();
            driver.Run(channelFactory.Create()).Wait();

            // UDP
            channelFactory.Type = ChannelType.Udp;
            driver.Run(channelFactory.Create()).Wait();
        }