예제 #1
0
        //supports just one server for now
        public LoadBalancer(String servers)
        {
            int portIdx = servers.LastIndexOf(':');
              String address = servers.Substring(0, portIdx);
              int port = int.Parse(servers.Substring(portIdx + 1, servers.Length - portIdx - 1));

              _pool = new HmuxChannelFactory(address, port);

              Init();
        }
예제 #2
0
        public HmuxChannel(Socket socket, HmuxChannelFactory pool)
        {
            _socket = socket;
              _stream = new BufferedStream(new NetworkStream(_socket));
              _pool = pool;
              _traceId = _socket.Handle.ToInt32().ToString();
              _log = Logger.GetLogger();

              _connProbe = pool.GetConnectionProbe();
              _requestTimeProbe = pool.GetRequestTimeProbe();
              _idleProbe = pool.GetIdleProbe();
        }
        public HmuxChannel OpenServer(String sessionId, HmuxChannelFactory xChannelFactory)
        {
            HmuxChannel channel = OpenRecycle();

              if (channel != null)
            return channel;

              Socket hmuxSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
              hmuxSocket.Connect(_address, _port);
              channel = new HmuxChannel(hmuxSocket, this);

              return channel;
        }
예제 #4
0
 public HmuxChannel OpenServer(String sessionId, HmuxChannelFactory xChannelFactory)
 {
     return _pool.OpenServer(sessionId, xChannelFactory);
 }