Beispiel #1
0
 public ChannelClientScope(bool autoTick, string channelName, ChannelClientHandler handler, bool closeClientOnExit = true)
 {
     m_CloseClientOnExit = closeClientOnExit;
     client = ChannelClient.GetOrCreateClient(channelName);
     m_Off  = client.On(handler);
     client.Start(autoTick);
 }
Beispiel #2
0
        public Action On(ChannelClientHandler handler)
        {
            if (m_Handlers.Contains(handler))
            {
                throw new Exception("Channel Client Handler already registered");
            }

            m_Handlers.Add(handler);

            return(() =>
            {
                Off(handler);
            });
        }
        public async Task RunEngineAsync(string ip, int port, ICustomizeHandler handler)
        {
            this.channelClientHandler = new ChannelClientHandler(handler);
            this.BasicOutter          = new BasicOutter(channelClientHandler.MessageBus);
            var group     = new MultithreadEventLoopGroup();
            var bootstrap = new Bootstrap();

            bootstrap
            .Group(group)
            .Channel <TcpSocketChannel>()
            .Option(ChannelOption.TcpNodelay, true)
            .Handler(new ActionChannelInitializer <ISocketChannel>(channel =>
            {
                IChannelPipeline pipeline = channel.Pipeline;
                //pipeline.AddLast(new LoggingHandler());
                pipeline.AddLast(OFrameDecoder.NewOFrameDecoder());
                pipeline.AddLast(this.channelClientHandler);
                pipeline.AddLast();
            }));

            IChannel clientChannel = await bootstrap.ConnectAsync(new IPEndPoint(IPAddress.Parse(ip), port));
        }
Beispiel #4
0
 public void Off(ChannelClientHandler handler)
 {
     m_Handlers.Remove(handler);
 }