Akka.Remote.TestKit.RemoteConnection.CreateConnection C# (CSharp) Метод

CreateConnection() публичный статический Метод

public static CreateConnection ( Role role, IPEndPoint socketAddress, int poolSize, IChannelHandler upstreamHandler ) : Task
role Role
socketAddress System.Net.IPEndPoint
poolSize int
upstreamHandler IChannelHandler
Результат Task
        public static Task<IChannel> CreateConnection(Role role, IPEndPoint socketAddress, int poolSize, IChannelHandler upstreamHandler)
        {
            if (role == Role.Client)
            {
                var connection = new ClientBootstrap()
                    .Channel<TcpSocketChannel>()
                    .Option(ChannelOption.TcpNodelay, true)
                    .Group(GetClientWorkerPool(poolSize))
                    .Handler(new ActionChannelInitializer<TcpSocketChannel>(channel =>
                    {
                        ApplyChannelPipeline(channel, upstreamHandler);
                    }));

                return connection.ConnectAsync(socketAddress);
            }
            else //server
            {
                var connection = new ServerBootstrap()
                    .Group(GetServerPool(poolSize), GetServerWorkerPool(poolSize))
                    .Channel<TcpServerSocketChannel>()
                    .ChildOption(ChannelOption.TcpNodelay, true)
                    .ChildHandler(new ActionChannelInitializer<TcpSocketChannel>(channel =>
                    {
                        ApplyChannelPipeline(channel, upstreamHandler);
                    }));
                return connection.BindAsync(socketAddress);
            }
        }

Usage Example

Пример #1
0
 public Controller(int initialParticipants, INode controllerPort)
 {
     _connection = RemoteConnection.CreateConnection(Role.Server, controllerPort, _settings.ServerSocketWorkerPoolSize,
                                                     new ConductorHandler(Self, Logging.GetLogger(Context.System, typeof(ConductorHandler))));
     _barrier             = Context.ActorOf(Props.Create <BarrierCoordinator>(), "barriers");
     _initialParticipants = initialParticipants;
 }
All Usage Examples Of Akka.Remote.TestKit.RemoteConnection::CreateConnection