Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

Gabiras12
Copy link

As requested by issue #59 my use case is the same. I need to pass a token on every connection attempt and it's only possible to use the token once. So the url must change on every reconnect attempt.

If url param is a function invoke it passing the attempt number

Solution:
Change the url param to be of type:

- string
- Promise<string>
- (attempt: number) => Promise<string>
- (attempt: number) => string

So the usage would look like:

// string as it is now
new Sockette('wss://address')
// promise style. just adding the setTimeout to simulate
new Sockette(new Promise((resolve) => {
  setTimeout(() => {
    resolve('wss://address')
  }, 5000)
}))

new Sockette(Promise.resolve('wss://address'))

new Sockette((attempt) => `wss://address?attempt${attempt}`)

new Sockette(async (attempt) => await Promise.resolve(`wss://address?attempt${attempt}`))

@Gabiras12
Copy link
Author

@lukeed can we have this merged?

@ghost
Copy link

ghost commented Jul 10, 2021

+1 to @Gabiras12
@lukeed let us know if this PR could be merged and released.

@exaucae
Copy link

exaucae commented Oct 31, 2021

bump!

@Gabiras12
Copy link
Author

@ghost and @exaucae I've published this PR under sockette-dynamic-url
https://www.npmjs.com/package/sockette-dynamic-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

Successfully merging this pull request may close these issues.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.