Skip to content

Commit f440715

Browse files
committed
Update README.md
1 parent acc3552 commit f440715

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,19 @@ SocketIOClient client = new SocketIOClient(URI.create("wss://example.com"), new
6767
public void on(String event, JSONArray arguments) {
6868
Log.d(TAG, String.format("Got event %s: %s", event, arguments.toString()));
6969
}
70+
71+
@Override
72+
public void onJSON(JSONObject json) {
73+
try {
74+
Log.d(TAG, String.format("Got JSON Object: %s", json.toString()));
75+
} catch(JSONException e) {
76+
}
77+
}
78+
79+
@Override
80+
public void onMessage(String message) {
81+
Log.d(TAG, String.format("Got message: %s", message));
82+
}
7083

7184
@Override
7285
public void onDisconnect(int code, String reason) {
@@ -82,12 +95,14 @@ SocketIOClient client = new SocketIOClient(URI.create("wss://example.com"), new
8295
client.connect();
8396

8497
// Later…
98+
client.emit("Message"); //Message
8599
JSONArray arguments = new JSONArray();
86100
arguments.put("first argument");
87101
JSONObject second = new JSONObject();
102+
client.emit(second); //JSON Message
88103
second.put("dictionary", true);
89104
arguments.put(second);
90-
client.emit("hello", arguments);
105+
client.emit("hello", arguments); //Event
91106
client.disconnect();
92107
```
93108

0 commit comments

Comments
 (0)