davinkevin / AngularStompDK

Angular service to communicate to Stomp-Websocket
http://davinkevin.github.io/AngularStompDK/
Apache License 2.0
36 stars 12 forks source link

Allow on-connect headers #47

Closed franDayz closed 7 years ago

franDayz commented 7 years ago

Currently headers can be provided via .withHeaders() when subscribing. However there are scenarios in which it is required to specify headers when connecting, for example in order to have a a durable subscriber to an ActiveMQ topic. You need to specify a client id on connect and subscription name on subscribe, which looks like this with pure stomp.js:

    var headers = {
      'client-id': 'my-client-id'
    };

    var client = Stomp.client('ws://localhost:61614');

    client.connect(headers, function(frame) {
      client.subscribe(
        '/topic/person',
        function(message) {
            $scope.addMessage(message);
            console.log(message);
        },
        {
          'activemq.subscriptionName': 'my-subscription-name'
        }
      );
    });

It would be cool to have something like this

ngstompProvider
    .url('ws://localhost:61614')
    .withHeaders({'client-id': 'my-client-id'});
davinkevin commented 7 years ago

Ok, I've done in in test env, if all is ok, I'll commit and release it tomorrow.

The method on the provider will have be .headers({foo: 'bar'})

davinkevin commented 7 years ago

You can find this in the release 0.11.0

davinkevin commented 7 years ago

Don't hesitate to open an issue if you found a bug. I've checked if there is any regression, but I don't have system working with header on connection to test it.

franDayz commented 7 years ago

Thanks! Works like a charm :D

davinkevin commented 7 years ago

Glad to know it 😄

LouisWayne commented 7 years ago

Thanks for the support!!