File tree Expand file tree Collapse file tree
websockets/src/main/java/com/craftsman/websockets Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ public class WsImpl implements Ws {
1818
1919 final String TAG = "Web Socket Impl" ;
2020
21- final AutobahnConnection autobahnConnection = new AutobahnConnection ();
21+ AutobahnConnection autobahnConnection = new AutobahnConnection ();
2222 final List <Payload > subscriptions = new ArrayList <>();
2323 String serverUrl ;
2424
@@ -103,13 +103,29 @@ public void onEvent(String s, Object o) {
103103 }
104104
105105 @ Override
106- public void send (String channelPath , String text ) {
106+ public void send ( String text ) {
107+ if (autobahnConnection .isConnected ())
108+ autobahnConnection .sendTextMessage (text );
109+ }
107110
111+ @ Override
112+ public void send ( byte [] binary ) {
113+ if (autobahnConnection .isConnected ())
114+ autobahnConnection .sendBinaryMessage (binary );
108115 }
109116
110117 @ Override
111- public void send (String channelPath , byte [] binary ) {
118+ public void send (String channelPath , Object o ) {
119+ if (autobahnConnection .isConnected ())
120+ autobahnConnection .publish (channelPath ,o );
121+ }
112122
123+ @ Override
124+ public void end () {
125+ if (autobahnConnection != null && autobahnConnection .isConnected ()) {
126+ autobahnConnection .unsubscribe ();
127+ autobahnConnection = null ;
128+ }
113129 }
114130
115131 final private class Payload <T >{
You can’t perform that action at this time.
0 commit comments