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

Please add methods to retrieve connection options. #888

Closed
voger opened this issue Mar 5, 2021 · 1 comment
Closed

Please add methods to retrieve connection options. #888

voger opened this issue Mar 5, 2021 · 1 comment

Comments

@voger
Copy link

voger commented Mar 5, 2021

Is your feature request related to a problem? Please describe.
It would be nice if the connection object could have some methods to retrieve connection details such as the address or domain.
They are indeed values provided by the user during connection initialization but may be useful later in the application runtime.

They could be saved by the application somewhere but retrieving them directly from the connection object would offer a central
place of storing them, instead of having them stored twice, one copy in the connection object and another in some application data structure. That would probably require additional code to ensure that both copies are in sync.

Also, the domain option is optional and can be derived from service. It would be nice to retrieve that derived domain instead of having to rewrite the logic to extract the domain from the service.

Describe the solution you'd like
As per package`s client example

const { client, xml } = require("@xmpp/client");
const debug = require("@xmpp/debug");

const xmpp = client({
  service: "ws://localhost:5280/xmpp-websocket",
  domain: "localhost",
  resource: "example",
  username: "username",
  password: "password",
});

// returns "ws://localhost:5280/xmpp-websocket"
xmpp.getService()

// returns "localhost"
xmpp.getDomain()

// returns "example"
xmpp.getResource()

// returns "username"
xmpp.getUsername()

// Not sure about this one
// returns "password"
xmpp.getPassword()
@sonnyp
Copy link
Member

sonnyp commented Jun 18, 2021

Can you share a use case for this?

@sonnyp sonnyp closed this as completed Jan 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants