Browse Source

Merge branch 'master' of github.com:mrniko/netty-socketio

master
Nikita 12 years ago
parent
commit
86dc36ebda
  1. 66
      README.md

66
README.md

@ -24,11 +24,16 @@ Usage example
================================ ================================
##Server ##Server
Base configuration. More details about Configuration object is [here](https://github.com/mrniko/netty-socketio/wiki/Configuration-details).
Configuration config = new Configuration(); Configuration config = new Configuration();
config.setHostname("localhost"); config.setHostname("localhost");
config.setPort(81); config.setPort(81);
SocketIOServer server = new SocketIOServer(config); SocketIOServer server = new SocketIOServer(config);
Programmatic handlers binding:
server.addMessageListener(new DataListener<String>() { server.addMessageListener(new DataListener<String>() {
@Override @Override
public void onData(SocketIOClient client, String message, AckRequest ackRequest) { public void onData(SocketIOClient client, String message, AckRequest ackRequest) {
@ -74,14 +79,57 @@ Usage example
client.sendJsonObject(obj); 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 ##Client
@ -121,4 +169,4 @@ Usage example
}); });
</script>
</script>
Loading…
Cancel
Save