public RemoteConnection(IConnection underlyingConnection, IHeliosConnectionHandler handler) : base(underlyingConnection) { _msgDecoder = new MsgDecoder(); _msgEncoder = new MsgEncoder(); _protobufDecoder = new ProtobufDecoder(TCP.Wrapper.DefaultInstance); _handler = handler; }
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); } }
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; } }