예제 #1
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="TcpServer" /> class.
 /// </summary>
 /// <param name="port">The port.</param>
 /// <param name="loggingService">The logging service.</param>
 /// <param name="clientHandlerFactory">The client handler factory.</param>
 public TcpServer(int port, ILoggingService loggingService, IClientHandlerFactory clientHandlerFactory)
 {
     _clientHandlerFactory = clientHandlerFactory;
     _port               = port;
     _loggingService     = loggingService;
     _clientHandlersList = new List <ITcpClientHandler>();
     Start();
 }
예제 #2
0
        public NewsBlurClient(IClientHandlerFactory handlerFactory, ILogger logger, string userAgent = "NewsBlurSharp")
        {
            _handlerFactory = handlerFactory;
            _userAgent      = userAgent;
            _handler        = GetHandlerFromFactory(handlerFactory);

            _httpClient = CreateHttpClient();
            _logger     = logger ?? new NullLogger();
        }
예제 #3
0
 public RpcServer(IPEndPoint listenEndpoint, IClientHandlerFactory clientHandlerFactory)
 {
     _listenEndpoint       = listenEndpoint;
     _clientHandlerFactory = clientHandlerFactory;
     _listenSocket         = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
     _listenSocket.Bind(_listenEndpoint);
     _listenSocket.Listen(10);
     _log.InfoFormat("Created server on {0} with handler {1}", listenEndpoint, clientHandlerFactory);
     BeginWaitForConnection();
 }
예제 #4
0
 public RpcServer(IPEndPoint listenEndpoint, IClientHandlerFactory clientHandlerFactory)
 {
     _listenEndpoint = listenEndpoint;
     _clientHandlerFactory = clientHandlerFactory;
     _listenSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
     _listenSocket.Bind(_listenEndpoint);
     _listenSocket.Listen(10);
     _log.InfoFormat("Created server on {0} with handler {1}", listenEndpoint, clientHandlerFactory);
     BeginWaitForConnection();
 }
예제 #5
0
        /// <summary>
        /// Initialize a new server
        /// </summary>
        /// <param name="addr">IP address of TCP listener</param>
        /// <param name="port">port number of TCP listener</param>
        /// <param name="serverActions">Instance of server actions class</param>
        /// <param name="clientHandler">Instance of client handler class</param>
        public Server(IPAddress addr, int port, IClientHandlerFactory clientHandlerFacotry, IServerActions serverActions = null)
        {
            this.Address = addr;
            this.Port = port;
            this.clientHandlerFactory = clientHandlerFacotry;
            this.serverActions = serverActions;

            this.listener = new TcpListener(Address, Port);
            clients = new Dictionary<string, TcpClient>();
        }
예제 #6
0
 public ClacksServer(IPEndPoint listenEndpoint, IClacksInstrumentation instrumentation, IClientHandlerFactory clientHandlerFactory) {
     _listenEndpoint = listenEndpoint;
     _instrumentation = instrumentation;
     _clientHandlerFactory = clientHandlerFactory;
     _listenSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp) { NoDelay = true };
     _listenSocket.Bind(_listenEndpoint);
     _listenSocket.Listen((int) SocketOptionName.MaxConnections);
     _log.InfoFormat("Created server on {0} with handler {1}", listenEndpoint, clientHandlerFactory);
     BeginWaitForConnection();
 }
예제 #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultClientConnector"/> class.
 /// </summary>
 /// <param name="clientLookup">
 /// The client lookup.
 /// </param>
 /// <param name="clientHandlerFactory">
 /// The client handler factory.
 /// </param>
 /// <param name="messageConstructor">
 /// The message constructor.
 /// </param>
 /// <param name="messageSideChannel">
 /// The message side channel.
 /// </param>
 public DefaultClientConnector(
     IClientLookup clientLookup,
     IClientHandlerFactory clientHandlerFactory,
     IMessageConstructor messageConstructor,
     IMessageSideChannel messageSideChannel)
 {
     this.m_ClientLookup         = clientLookup;
     this.m_ClientHandlerFactory = clientHandlerFactory;
     this.m_MessageConstructor   = messageConstructor;
     this.m_MessageSideChannel   = messageSideChannel;
 }
예제 #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultClientConnector"/> class.
 /// </summary>
 /// <param name="clientLookup">
 /// The client lookup.
 /// </param>
 /// <param name="clientHandlerFactory">
 /// The client handler factory.
 /// </param>
 /// <param name="messageConstructor">
 /// The message constructor.
 /// </param>
 /// <param name="messageSideChannel">
 /// The message side channel.
 /// </param>
 public DefaultClientConnector(
     IClientLookup clientLookup, 
     IClientHandlerFactory clientHandlerFactory, 
     IMessageConstructor messageConstructor, 
     IMessageSideChannel messageSideChannel)
 {
     this.m_ClientLookup = clientLookup;
     this.m_ClientHandlerFactory = clientHandlerFactory;
     this.m_MessageConstructor = messageConstructor;
     this.m_MessageSideChannel = messageSideChannel;
 }
예제 #9
0
        private HttpClientHandler GetHandlerFromFactory(IClientHandlerFactory handlerFactory)
        {
            var handler = handlerFactory?.CreateHandler() as HttpClientHandler ?? new HttpClientHandler();

            SetCookieSessionId(_cookieSessionId);
            handler.CookieContainer       = _cookieJar;
            handler.UseCookies            = true;
            handler.UseDefaultCredentials = false;

            return(handler);
        }
예제 #10
0
 public DefaultConnectionHandler(IClientHandlerFactory clientHandlerFactory, IClientLookup clientLookup)
 {
     this.m_ClientHandlerFactory = clientHandlerFactory;
     this.m_ClientLookup = clientLookup;
 }
예제 #11
0
 /// <summary>
 /// Initialize a new server
 /// </summary>
 /// <param name="port">port number of TCP listener</param>
 /// <param name="serverActions">Instance of server actions class</param>
 /// <param name="clientHandler">Instance of client handler class</param>
 public Server(int port, IClientHandlerFactory clientHandlerFacotry, IServerActions serverActions = null)
     : this(IPAddress.Loopback, port, clientHandlerFacotry, serverActions)
 {
 }
예제 #12
0
 private ServerBuilder(IPEndPoint endPoint, bool isAsync) {
     _endPoint = endPoint;
     _clientHandlerFactory = isAsync
         ? (IClientHandlerFactory)new AsyncClientHandlerFactory(_asyncRepository)
         : new SyncClientHandlerFactory(_syncRepository);
 }
예제 #13
0
 public DefaultConnectionHandler(IClientHandlerFactory clientHandlerFactory, IClientLookup clientLookup)
 {
     this.m_ClientHandlerFactory = clientHandlerFactory;
     this.m_ClientLookup         = clientLookup;
 }
예제 #14
0
 public NewsBlurClient(IClientHandlerFactory handlerFactory)
     : this(handlerFactory, new NullLogger())
 {
 }