Search in sources :

Example 1 with ReconnectableConnector

use of com.generallycloud.baseio.connector.ReconnectableConnector in project baseio by generallycloud.

the class TestReconnectClient method main.

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

        @Override
        public void accept(SocketSession session, Future future) throws Exception {
        }
    };
    SocketChannelContext context = new NioSocketChannelContext(new ServerConfiguration("localhost", 8300));
    ReconnectableConnector connector = new ReconnectableConnector(context);
    connector.setRetryTime(5000);
    context.setIoEventHandleAdaptor(eventHandleAdaptor);
    context.addSessionEventListener(new LoggerSocketSEListener());
    context.setProtocolFactory(new FixedLengthProtocolFactory());
    // context.addSessionEventListener(new CloseConnectorSEListener(connector.getRealConnector()));
    connector.connect();
    ThreadUtil.sleep(Long.MAX_VALUE);
    CloseUtil.close(connector);
}
Also used : ReconnectableConnector(com.generallycloud.baseio.connector.ReconnectableConnector) LoggerSocketSEListener(com.generallycloud.baseio.component.LoggerSocketSEListener) SocketSession(com.generallycloud.baseio.component.SocketSession) FixedLengthProtocolFactory(com.generallycloud.baseio.codec.fixedlength.FixedLengthProtocolFactory) ServerConfiguration(com.generallycloud.baseio.configuration.ServerConfiguration) IoEventHandleAdaptor(com.generallycloud.baseio.component.IoEventHandleAdaptor) Future(com.generallycloud.baseio.protocol.Future) SocketChannelContext(com.generallycloud.baseio.component.SocketChannelContext) NioSocketChannelContext(com.generallycloud.baseio.component.NioSocketChannelContext) NioSocketChannelContext(com.generallycloud.baseio.component.NioSocketChannelContext)

Aggregations

FixedLengthProtocolFactory (com.generallycloud.baseio.codec.fixedlength.FixedLengthProtocolFactory)1 IoEventHandleAdaptor (com.generallycloud.baseio.component.IoEventHandleAdaptor)1 LoggerSocketSEListener (com.generallycloud.baseio.component.LoggerSocketSEListener)1 NioSocketChannelContext (com.generallycloud.baseio.component.NioSocketChannelContext)1 SocketChannelContext (com.generallycloud.baseio.component.SocketChannelContext)1 SocketSession (com.generallycloud.baseio.component.SocketSession)1 ServerConfiguration (com.generallycloud.baseio.configuration.ServerConfiguration)1 ReconnectableConnector (com.generallycloud.baseio.connector.ReconnectableConnector)1 Future (com.generallycloud.baseio.protocol.Future)1