Search in sources :

Example 11 with ChannelAcceptor

use of com.firenio.component.ChannelAcceptor in project baseio by generallycloud.

the class TestProtobaseServer method main.

public static void main(String[] args) throws Exception {
    IoEventHandle eventHandleAdaptor = new IoEventHandle() {

        @Override
        public void accept(Channel ch, Frame f) throws Exception {
            String text = f.getStringContent();
            f.setContent(ch.allocateWithSkipHeader(1));
            f.write("yes server already accept your message:", ch);
            f.write(text, ch);
            ch.writeAndFlush(f);
        }
    };
    ChannelAcceptor context = new ChannelAcceptor(8300);
    context.addChannelEventListener(new LoggerChannelOpenListener());
    context.setIoEventHandle(eventHandleAdaptor);
    context.addProtocolCodec(new ProtobaseCodec());
    context.bind();
}
Also used : IoEventHandle(com.firenio.component.IoEventHandle) Frame(com.firenio.component.Frame) Channel(com.firenio.component.Channel) ChannelAcceptor(com.firenio.component.ChannelAcceptor) ProtobaseCodec(com.firenio.codec.protobase.ProtobaseCodec) LoggerChannelOpenListener(com.firenio.component.LoggerChannelOpenListener)

Aggregations

ChannelAcceptor (com.firenio.component.ChannelAcceptor)11 LoggerChannelOpenListener (com.firenio.component.LoggerChannelOpenListener)10 Channel (com.firenio.component.Channel)9 Frame (com.firenio.component.Frame)8 IoEventHandle (com.firenio.component.IoEventHandle)8 NioEventLoopGroup (com.firenio.component.NioEventLoopGroup)5 HttpCodec (com.firenio.codec.http11.HttpCodec)3 HttpFrame (com.firenio.codec.http11.HttpFrame)3 LengthValueCodec (com.firenio.codec.lengthvalue.LengthValueCodec)3 ByteBuf (com.firenio.buffer.ByteBuf)2 WebSocketCodec (com.firenio.codec.http11.WebSocketCodec)2 Http2Codec (com.firenio.codec.http2.Http2Codec)2 ChannelAliveListener (com.firenio.component.ChannelAliveListener)2 ChannelEventListenerAdapter (com.firenio.component.ChannelEventListenerAdapter)2 ThreadEventLoopGroup (com.firenio.concurrent.ThreadEventLoopGroup)2 CountChannelListener (sample.http11.service.CountChannelListener)2 LifeCycle (com.firenio.LifeCycle)1 LifeCycleListener (com.firenio.LifeCycleListener)1 ClientHttpCodec (com.firenio.codec.http11.ClientHttpCodec)1 ClientHttpFrame (com.firenio.codec.http11.ClientHttpFrame)1