예제 #1
0
 public RemoteConnection(IConnection underlyingConnection, IHeliosConnectionHandler handler) : base(underlyingConnection)
 {
     _msgDecoder      = new MsgDecoder();
     _msgEncoder      = new MsgEncoder();
     _protobufDecoder = new ProtobufDecoder(TCP.Wrapper.DefaultInstance);
     _handler         = handler;
 }
예제 #2
0
 public RemoteConnection(IConnection underlyingConnection, IHeliosConnectionHandler handler) : base(underlyingConnection)
 {
     _msgDecoder = new MsgDecoder();
     _msgEncoder = new MsgEncoder();
     _protobufDecoder = new ProtobufDecoder(TCP.Wrapper.DefaultInstance);
     _handler = handler;
 }
예제 #3
0
 public static RemoteConnection CreateConnection(Role role, INode socketAddress, int poolSize, IHeliosConnectionHandler upstreamHandler)
 {
     if (role == Role.Client)
     {
         var connection = new ClientBootstrap().SetTransport(TransportType.Tcp)
                          .SetOption("TcpNoDelay", true)
                          .SetEncoder(Encoders.DefaultEncoder) //LengthFieldPrepender
                          .SetDecoder(Encoders.DefaultDecoder) //LengthFieldFrameBasedDecoder
                          .WorkerThreads(poolSize).Build().NewConnection(socketAddress);
         var remoteConnection = new RemoteConnection(connection, upstreamHandler);
         remoteConnection.Open();
         return(remoteConnection);
     }
     else //server
     {
         var connection = new ServerBootstrap().SetTransport(TransportType.Tcp)
                          .SetOption("TcpNoDelay", true)
                          .SetEncoder(Encoders.DefaultEncoder) //LengthFieldPrepender
                          .SetDecoder(Encoders.DefaultDecoder) //LengthFieldFrameBasedDecoder
                          .WorkerThreads(poolSize).Build().NewConnection(socketAddress);
         var remoteConnection = new RemoteConnection(connection, upstreamHandler);
         remoteConnection.Open();
         return(remoteConnection);
     }
 }
예제 #4
0
 public static RemoteConnection CreateConnection(Role role, INode socketAddress, int poolSize, IHeliosConnectionHandler upstreamHandler)
 {
     if (role == Role.Client)
     {
         var connection = new ClientBootstrap().SetTransport(TransportType.Tcp)
             .SetOption("TcpNoDelay", true)
             .SetEncoder(Encoders.DefaultEncoder) //LengthFieldPrepender
             .SetDecoder(Encoders.DefaultDecoder) //LengthFieldFrameBasedDecoder
             .WorkerThreads(poolSize).Build().NewConnection(socketAddress);
         var remoteConnection = new RemoteConnection(connection, upstreamHandler);
         remoteConnection.Open();
         return remoteConnection;
     }
     else //server
     {
         var connection = new ServerBootstrap().SetTransport(TransportType.Tcp)
             .SetOption("TcpNoDelay", true)
             .SetEncoder(Encoders.DefaultEncoder) //LengthFieldPrepender
             .SetDecoder(Encoders.DefaultDecoder) //LengthFieldFrameBasedDecoder
             .WorkerThreads(poolSize).Build().NewConnection(socketAddress);
         var remoteConnection = new RemoteConnection(connection, upstreamHandler);
         remoteConnection.Open();
         return remoteConnection;
     }
 }