ws.on not listen the events
Hi, I am using this library for my project to send and receive the data. I am able to connect websocket using this library but I am unable to subscribe the specific channel using this below code. // Subscriber ws.on("/topic/greetings", new Ws.WsListner() { @Override public void onEvent(String eventUri, Object data) { System.out.println("EVENT URI:: "+ eventUri); System.out.println("EVENT DATA IS:: "+ data); if(data != null) {
}
}
});
//Sender ws.send("/app/hello","Hello, welcome");
// End point Url String url = "ws://10.0.2.2:8080/hello";
Please check and do needful
Hi, excuse me to answer you late. We have done some update about the library. Try to use this snipet as example:
public class WebSocketManager {
private Ws ws;
public WebSocketManager() {
ws = new Ws.Builder().from("ws://" + App.getInstance().getSocketIP()
+ ":" + App.getInstance().getWebPort());
}
public void connect() throws Exception {
if (ws != null) ws.connect();
}
public void disconnect(){
if (ws != null) ws.end();
}
public Ws getWs() {
return ws;
}
public void changeURI(String host, String port) throws Exception {
if (ws != null) {
((WsImpl) ws).changeSocketURI(host, port);
}
}
}