Open so1337 opened 8 years ago
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();
})
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?
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.