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

Set realm from variable #45

Open
so1337 opened this issue Feb 17, 2016 · 2 comments
Open

Set realm from variable #45

so1337 opened this issue Feb 17, 2016 · 2 comments

Comments

@so1337
Copy link

so1337 commented Feb 17, 2016

We're working on messaging app .
First - I login, and then I'm setting the realm name ('realm_'+username);
Now what I'm doing is
$wamp.connection._ options.realm = 'realm_'+$cookies.get('key');
$wamp.open();
But I think it's not good in practice, because sometimes, when wamp is closing socket and reconnecting - the behavior of socket becomes unpredictable , so your only solution is to restart the page.
Is there any method to set custom realm after login and not doin "$wamp.connection._options.realm " this thingy ?
Because there's method setAuthId and It'll be useful to have a method setRealm.

@davidwdan
Copy link
Member

I haven't tested this, but something like this should work:

//create a service that wraps the $wampProvider
.provider('myWamp', function (myWampProvider) {
    this.$get = function ($rootScope, $q, $log, $cookies) {
        var options = {
            url: 'ws://127.0.0.1:8080',
            realm: $cookies.get('key')
        };

        var wp = $wampProvider;
        wp.init(options);
        return wp.$get($rootScope, $q, $log);
    };
})

//in you controller
.controller('MyController', function(myWamp){
    myWamp.open();
})

@bondt
Copy link
Contributor

bondt commented Jun 13, 2016

I actually agree with @so1337 here. Why is the only setting changeable from the outside the authId? Shouldn't all of autobahn's connection options be prone to change, including the URL?

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

3 participants