JSteunou / webstomp-client

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

Stomp.connect should accept custom headers #45

Closed mk-codepool closed 7 years ago

mk-codepool commented 7 years ago

Hi, I'm using webstomp in Aurelia project, cause of possibility of .subscribe. In original repo .connect() accepts custom headers, like: .connect({'Authorization': 'Bearer 123'})

In your 'index.d.ts' i see, that connect accepts only:

... before callback function, but ConnectionHeader interface contains only: login: string; passcode: string; host?: string; If I change it to any, Stomp sends request as ussualy with my custom header.

My example:

websocketConnect(){
    var socket = new SockJS('https://my-rul');
    var stompClient = Stomp.over(socket);
    var token = `Bearer ${this.authService.getAccessToken()}`;
    stompClient.connect({'Authorization' : token}, frame => {
        stompClient.subscribe('/some-subchannel', msg => {
            // ...
        });
    });
}
JSteunou commented 7 years ago

Feel free to open a PR on the .ts I do not and will never maintain it by myself

JSteunou commented 7 years ago

closed by #46