diff --git a/README.md b/README.md index af49d94..a5a7f13 100644 --- a/README.md +++ b/README.md @@ -24,11 +24,16 @@ Usage example ================================ ##Server +Base configuration. More details about Configuration object is [here](https://github.com/mrniko/netty-socketio/wiki/Configuration-details). + Configuration config = new Configuration(); config.setHostname("localhost"); config.setPort(81); SocketIOServer server = new SocketIOServer(config); + +Programmatic handlers binding: + server.addMessageListener(new DataListener() { @Override public void onData(SocketIOClient client, String message, AckRequest ackRequest) { @@ -74,14 +79,57 @@ Usage example client.sendJsonObject(obj); } }); - - server.start(); - - - ... - - - server.stop(); + +Declarative handlers binding. Handlers could be bound via annotations on any object: + + pubic class SomeBusinessService { + + ... + // some stuff code + ... + + // only data object is required in arguments, + // SocketIOClient and AckRequest could be ommited + @OnEvent('someevent') + public void onSomeEventHandler(SocketIOClient client, SomeClass data, AckRequest ackRequest) { + ... + } + + @OnConnect + public void onConnectHandler(SocketIOClient client) { + ... + } + + @OnDisconnect + public void onDisconnectHandler(SocketIOClient client) { + ... + } + + // only data object is required in arguments, + // SocketIOClient and AckRequest could be ommited + @OnJsonObject + public void onSomeEventHandler(SocketIOClient client, SomeClass data, AckRequest ackRequest) { + ... + } + + // only data object is required in arguments, + // SocketIOClient and AckRequest could be ommited + @OnMessage + public void onSomeEventHandler(SocketIOClient client, String data, AckRequest ackRequest) { + ... + } + + } + + SomeBusinessService someService = new SomeBusinessService(); + server.addListeners(someService); + + + server.start(); + + ... + + server.stop(); ##Client @@ -121,4 +169,4 @@ Usage example }); - \ No newline at end of file +