JSteunou / webstomp-client

Stomp client over websocket for browsers
Apache License 2.0
299 stars 59 forks source link

Multiple subscribes #64

Closed nephilimboy closed 6 years ago

nephilimboy commented 6 years ago

hi I want to use Multiple subscribes, like this:

connecting() {
        const socket = new SockJS('/rest/websocket/chat');
        this.stompClient = Stomp.over(socket);
        const headers = {};
        this.stompClient.connect(headers, this.onConnected());
    }

    onConnected() {

        this.stompClient.subscribe('/topic/channel/' + '1', (message) => {
         // SOMETHING TO DO
        });
        this.stompClient.subscribe('/topic/seenUpdate/' + '1', (message) => {
        // SOMETHING TO DO
        });
}

but when i run this, only my first subscribe work, here is the log on console.

>>> SUBSCRIBE
id:sub-1513079223083-564
destination:/topic/channel/1

so how can i make it work with multiple subscribe? btw i'm using Angular 4+ with webpack. Thanks in advance

JSteunou commented 6 years ago

Please look at the examples and your broker documentation

https://github.com/JSteunou/webstomp-client/tree/master/example