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

There is no way to change Client authid #33

Open
andzejsw opened this issue Dec 3, 2019 · 5 comments
Open

There is no way to change Client authid #33

andzejsw opened this issue Dec 3, 2019 · 5 comments

Comments

@andzejsw
Copy link

andzejsw commented Dec 3, 2019

In my app I need first to start anonymous connection. After that i get access token, which one i use as authid. So far i haven't seen a way to change authid for a client.
Currently i am recreating client with new authid. Is there better way?

@davidwdan
Copy link
Member

You can use a subject or observable to configure the client, which will allow you to change the config on the fly.

const config = new BehaviorSubject({
  url: "ws://127.0.0.1:9090",
  realm: "realm1"
});

const wamp = new Client(config);

// Once you get the authid

config.next({
  url: "ws://127.0.0.1:9090",
  realm: "realm1",
  options: {
    authid: 'dave'
  }
});

@andzejsw
Copy link
Author

andzejsw commented Dec 5, 2019

In this way app is not connecting to ws. But there is also no error thrown. My config looks like this:

private config = new BehaviorSubject({
        url: this.configuration.api.url,
        realm: this.configuration.api.realm,
        options: {
            authmethods: this.configuration.api.authmethods,
            authid: this.getAuthId(),
        }
    });

authid exists, so there is no problem with that.

@andzejsw
Copy link
Author

andzejsw commented Jan 31, 2020

Returning to this one.
Error on this is TypeError: urlOrTransportOrObs.map is not a function

Stack Trace:

main.ts:12 TypeError: urlOrTransportOrObs.map is not a function
    at new Client (Client.js:126)
    at new WampService (WampService.ts:29)

WampService.ts:29 line is: this.client = new Client(this.config);

@davidwdan
Copy link
Member

What version of rxjs are you using and do you have the rxjs-compat package installed?

@andzejsw
Copy link
Author

andzejsw commented Jan 31, 2020

What version of rxjs are you using and do you have the rxjs-compat package installed?

"rxjs": "^6.5.4",
"rxjs-compat": "^6.5.4",

Latest stable. :)

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

2 participants