Ejemplo n.º 1
0
 public TcpConnectionPair(PresentationBuilder <TOriginContractInterface> originBuilder,
                          PresentationBuilder <TProxyContractInterface> proxyBuider, bool connect = true)
 {
     Server               = originBuilder.CreateTcpServer(IPAddress.Loopback, 12345);
     ClientChannel        = new TcpChannel();
     ProxyConnection      = proxyBuider.UseChannel(ClientChannel).Build();
     _eventAwaiter        = new EventAwaiter <IConnection <TOriginContractInterface, TcpChannel> >();
     Server.AfterConnect += _eventAwaiter.EventRaised;
     if (connect)
     {
         Connect();
     }
 }
Ejemplo n.º 2
0
        public Server()
        {
            _tntServer = TntBuilder
                         //Using contract factory. ServerSideContractImplementation exemplar needs reference to broadcast method:
                         .UseContract <IStage2Contract>(() => new Stage2ContractImplementation(this))
                         .CreateTcpServer(IPAddress.Any, 12345);

            //alow only 10 connections at the moment:
            _tntServer.BeforeConnect += (_, arg) =>
            {
                if (_tntServer.ConnectionsCount >= 10)
                {
                    arg.AllowConnection = false;
                }
            };
            _tntServer.StartListening();
            Console.WriteLine("Server opened");
        }
Ejemplo n.º 3
0
        public TcpConnectionPair(bool connect = true)
        {
            Server = TntBuilder
                     .UseContract <TOriginContractInterface, TOriginContractType>()
                     //  .UseReceiveDispatcher<NotThreadDispatcher>()
                     .SetMaxAnsDelay(200000)
                     .CreateTcpServer(IPAddress.Loopback, 12345);
            ClientChannel   = new TcpChannel();
            ProxyConnection = TntBuilder
                              .UseContract <TProxyContractInterface>()
                              // .UseReceiveDispatcher<NotThreadDispatcher>()
                              .SetMaxAnsDelay(200000)
                              .UseChannel(ClientChannel)
                              .Build();

            if (connect)
            {
                Connect();
            }
        }