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

Support for subscribe and publish Websocket API in Bun Adapter #3230

Open
newarifrh opened this issue Aug 4, 2024 · 2 comments
Open

Support for subscribe and publish Websocket API in Bun Adapter #3230

newarifrh opened this issue Aug 4, 2024 · 2 comments
Labels
enhancement New feature or request.

Comments

@newarifrh
Copy link
Contributor

What is the feature you are proposing?

Description

Currently, Hono.js's WebSocket helper provides several adapters, one of which is Bun. However, the Bun adapter only supports the send() API. According to the Bun WebSocket documentation, there are other useful APIs like subscribe and publish. These APIs can be used to send data/messages to users subscribed to the same topic. With the current send() API, messages have to be sent in a loop which is not efficient for broadcasting messages.

Use Case

  • Broadcast Messages: Efficiently send messages to all users subscribed to a specific topic.
  • Topic-Based Messaging: Allow users to subscribe to specific topics and receive relevant messages without sending individual messages in a loop.

Proposal

  • Implement support for subscribe and publish APIs in the Bun adapter.
  • Update the documentation to reflect the new capabilities.

Benefits

  • Improved efficiency in message broadcasting.
  • Enhanced flexibility in handling WebSocket connections and messages.

References

@newarifrh newarifrh added the enhancement New feature or request. label Aug 4, 2024
@newarifrh newarifrh changed the title Support for subscribe and publish API in Bun Adapter Support for subscribe and publish Websocket API in Bun Adapter Aug 4, 2024
@nakasyou
Copy link
Contributor

nakasyou commented Aug 4, 2024

It is capable without Bun, so I think that it's good that Hono will provide this API for all runtime as utils.

@newarifrh
Copy link
Contributor Author

Yes, I agree with that. However, I haven't seen if there are native APIs for other adapters. So far, I have been able to work for Bun adapter using native API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request.
Projects
None yet
Development

No branches or pull requests

2 participants