Search in sources :

Example 1 with ReConnector

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

the class TestReconnectClient method main.

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

        @Override
        public void accept(Channel ch, Frame frame) throws Exception {
        }
    };
    ChannelConnector context = new ChannelConnector(8300);
    ReConnector connector = new ReConnector(context);
    connector.setRetryTime(5000);
    context.setIoEventHandle(eventHandleAdaptor);
    context.addChannelEventListener(new LoggerChannelOpenListener());
    context.addProtocolCodec(new LengthValueCodec());
    // context.addChannelEventListener(new CloseConnectorSEListener(connector.getRealConnector()));
    connector.connect();
    int count = 99999;
    for (int i = 0; ; i++) {
        Util.sleep(1000);
        if (i > count) {
            break;
        }
    }
    Util.close(connector);
}
Also used : IoEventHandle(com.firenio.component.IoEventHandle) LengthValueCodec(com.firenio.codec.lengthvalue.LengthValueCodec) Frame(com.firenio.component.Frame) Channel(com.firenio.component.Channel) ChannelConnector(com.firenio.component.ChannelConnector) ReConnector(com.firenio.component.ReConnector) LoggerChannelOpenListener(com.firenio.component.LoggerChannelOpenListener)

Aggregations

LengthValueCodec (com.firenio.codec.lengthvalue.LengthValueCodec)1 Channel (com.firenio.component.Channel)1 ChannelConnector (com.firenio.component.ChannelConnector)1 Frame (com.firenio.component.Frame)1 IoEventHandle (com.firenio.component.IoEventHandle)1 LoggerChannelOpenListener (com.firenio.component.LoggerChannelOpenListener)1 ReConnector (com.firenio.component.ReConnector)1