Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ws.on not listen the events #1

Open
kuppasekhar opened this issue Jul 3, 2018 · 1 comment
Open

ws.on not listen the events #1

kuppasekhar opened this issue Jul 3, 2018 · 1 comment

Comments

@kuppasekhar
Copy link

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

@ghost
Copy link

ghost commented Jul 11, 2018

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);
        }
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant