From 4b9d28b60c0234b83938784e4e171f9b24c20999 Mon Sep 17 00:00:00 2001 From: Nikita Koksharov Date: Mon, 6 May 2013 22:11:58 +0400 Subject: [PATCH 1/2] Update README.md --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3579b02..7330ef3 100644 --- a/README.md +++ b/README.md @@ -23,11 +23,16 @@ Licensed under the Apache License 2.0. ##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) { @@ -120,4 +125,4 @@ Licensed under the Apache License 2.0. }); - \ No newline at end of file + From fd6201ba7834ff2a6c9f6107fbb438770115ceb2 Mon Sep 17 00:00:00 2001 From: Nikita Koksharov Date: Tue, 7 May 2013 15:41:00 +0400 Subject: [PATCH 2/2] Update README.md --- README.md | 55 +++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 49 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 7330ef3..a1c65e0 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ Base configuration. More details about Configuration object is [here](https://gi SocketIOServer server = new SocketIOServer(config); -Programmatic handlers binding +Programmatic handlers binding: server.addMessageListener(new DataListener() { @Override @@ -78,14 +78,57 @@ Programmatic handlers binding client.sendJsonObject(obj); } }); + +Declarative handlers binding. Handlers could be bound via annotations on any object: - server.start(); - + 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.stop(); + server.start(); + + ... + + server.stop(); ##Client