Skip to content

Commit

Permalink
Improve readme
Browse files Browse the repository at this point in the history
  • Loading branch information
NaikSoftware committed May 7, 2016
1 parent c503767 commit d1f2506
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer {
}
```

**HelloSockController**
**HelloSockController.groovy**
``` groovy
@RestController
class BoardSockController {
class HelloSockController {
@MessageMapping("/hello")
@SendTo("/topic/greetings")
public String greeting(String msg) throws Exception {
def greeting(String msg) throws Exception {
println("Receive greeting ${msg}")
return "ECHO: " + msg;
"ECHO: " + msg;
}
}
```
Expand All @@ -50,7 +50,7 @@ class BoardSockController {

// ...

mStompClient = Stomp.over(WebSocketClient.class, Config.STOMP_BASE_URI);
mStompClient = Stomp.over(WebSocketClient.class, "ws://localhost:8080/app/hello/websocket");
mStompClient.connect();

mStompClient.topic("/topic/greetings").subscribe(topicMessage -> {
Expand All @@ -65,15 +65,32 @@ class BoardSockController {

```

Method `Stomp.over` consume class for create connection as first parameter.
You must provide dependency for lib and pass class.
At now supported connection providers:
- WebSocketClient.class ('org.java-websocket:Java-WebSocket:1.3.0')

You can add own connection provider. Just implement interface `ConnectionProvider`.
If you implement new provider, please create pull request :)

**Subscribe lifecycle connection**
``` java
mStompClient.lifecycle().subscribe(lifecycleEvent -> {
switch (lifecycleEvent.getType()) {

case OPENED:
Log.d(TAG, "Stomp connection opened");
break;

case ERROR:
if (mCallback != null) mCallback.showError(lifecycleEvent.getException().getMessage());
Log.e(TAG, "Error", lifecycleEvent.getException());
break;

case CLOSED:
LOGD(TAG, "Stomp connection closed");
Log.d(TAG, "Stomp connection closed");
break;
}
});
```

Library support just send & receive messages. ACK messages, transactions not implemented yet.

0 comments on commit d1f2506

Please sign in to comment.