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); }
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[]> >(); }
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)); } }
public UdpCommunicationService(IApplicationContext applicationContext, ILoggerService loggerService, IBufferManagerFactory bufferManagerFactory, IPacketsHandler packetsHandler, INodesResolutionService nodesResolutionService) : base(applicationContext, loggerService, bufferManagerFactory, packetsHandler, nodesResolutionService) { }