Skip to content

Commit d1f2506

Browse files
committed
Improve readme
1 parent c503767 commit d1f2506

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

README.md

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@ public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer {
2828
}
2929
```
3030

31-
**HelloSockController**
31+
**HelloSockController.groovy**
3232
``` groovy
3333
@RestController
34-
class BoardSockController {
34+
class HelloSockController {
3535
3636
@MessageMapping("/hello")
3737
@SendTo("/topic/greetings")
38-
public String greeting(String msg) throws Exception {
38+
def greeting(String msg) throws Exception {
3939
println("Receive greeting ${msg}")
40-
return "ECHO: " + msg;
40+
"ECHO: " + msg;
4141
}
4242
}
4343
```
@@ -50,7 +50,7 @@ class BoardSockController {
5050

5151
// ...
5252

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

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

6666
```
6767

68+
Method `Stomp.over` consume class for create connection as first parameter.
69+
You must provide dependency for lib and pass class.
70+
At now supported connection providers:
71+
- WebSocketClient.class ('org.java-websocket:Java-WebSocket:1.3.0')
72+
73+
You can add own connection provider. Just implement interface `ConnectionProvider`.
74+
If you implement new provider, please create pull request :)
75+
6876
**Subscribe lifecycle connection**
6977
``` java
7078
mStompClient.lifecycle().subscribe(lifecycleEvent -> {
7179
switch (lifecycleEvent.getType()) {
80+
81+
case OPENED:
82+
Log.d(TAG, "Stomp connection opened");
83+
break;
84+
7285
case ERROR:
73-
if (mCallback != null) mCallback.showError(lifecycleEvent.getException().getMessage());
86+
Log.e(TAG, "Error", lifecycleEvent.getException());
7487
break;
88+
7589
case CLOSED:
76-
LOGD(TAG, "Stomp connection closed");
90+
Log.d(TAG, "Stomp connection closed");
91+
break;
7792
}
7893
});
7994
```
95+
96+
Library support just send & receive messages. ACK messages, transactions not implemented yet.

0 commit comments

Comments
 (0)