Esempio n. 1
0
        public void ConnectivityBaseTest(int listeningPort)
        {
            ICommunicationChannel clientHandler = Substitute.For <ICommunicationChannel>();

            ServiceLocator.Current.GetInstance <IUnityContainer>().RegisterInstance(clientHandler);

            ApplicationContext applicationContext = new ApplicationContext()
            {
                Container = (UnityContainer)ServiceLocator.Current.GetInstance <IUnityContainer>()
            };

            ILoggerService loggerService = Substitute.For <ILoggerService>();

            IBufferManagerFactory          bufferManagerFactory = Substitute.For <IBufferManagerFactory>();
            ServerCommunicationServiceBase communicationHub     = new TcpCommunicationService(applicationContext, loggerService, bufferManagerFactory, null, null);

            IPEndPoint             communicationEndPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), listeningPort);
            SocketListenerSettings settings = new SocketListenerSettings(1, 100, communicationEndPoint);

            communicationHub.Init(settings);
            communicationHub.Start();

            TcpClient tcpClient = new TcpClient();

            tcpClient.Connect(communicationEndPoint.Address, communicationEndPoint.Port);

            Assert.True(tcpClient.Connected);
        }
Esempio n. 2
0
 public CommunicationServiceBase(IApplicationContext applicationContext, ILoggerService loggerService, IBufferManagerFactory bufferManagerFactory, IPacketsHandler packetsHandler, INodesResolutionService nodesResolutionService)
 {
     _log = loggerService.GetLogger(GetType().Name);
     _applicationContext     = applicationContext;
     _bufferManagerFactory   = bufferManagerFactory;
     _packetsHandler         = packetsHandler;
     _clientConnectedList    = new List <ICommunicationChannel>();
     _nodesResolutionService = nodesResolutionService;
     _messagesQueue          = new BlockingCollection <KeyValuePair <IKey, byte[]> >();
 }
Esempio n. 3
0
        public TcpCommunicationService(IApplicationContext applicationContext, ILoggerService loggerService, IBufferManagerFactory bufferManagerFactory, IPacketsHandler packetsHandler, INodesResolutionService nodesResolutionService)
            : base(applicationContext, loggerService, bufferManagerFactory, packetsHandler, nodesResolutionService)
        {
            _acceptEventArgsPool = new GenericPool <SocketAsyncEventArgs>(10);

            for (Int32 i = 0; i < 10; i++)
            {
                _acceptEventArgsPool.Push(CreateNewSocketAsyncEventArgs(_acceptEventArgsPool));
            }
        }
Esempio n. 4
0
 public UdpCommunicationService(IApplicationContext applicationContext, ILoggerService loggerService, IBufferManagerFactory bufferManagerFactory, IPacketsHandler packetsHandler, INodesResolutionService nodesResolutionService)
     : base(applicationContext, loggerService, bufferManagerFactory, packetsHandler, nodesResolutionService)
 {
 }