@@ -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
8295client. connect();
8396
8497// Later…
98+ client. emit(" Message" ); // Message
8599JSONArray arguments = new JSONArray ();
86100arguments. put(" first argument" );
87101JSONObject second = new JSONObject ();
102+ client. emit(second); // JSON Message
88103second. put(" dictionary" , true );
89104arguments. put(second);
90- client. emit(" hello" , arguments);
105+ client. emit(" hello" , arguments); // Event
91106client. disconnect();
92107```
93108
0 commit comments