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
publish without peer #29
Comments
Sounds reasonable. Thinking more but i guess we can do it by introducing new setup hook and give an interface to it to interact. |
did you mean adding a new hook that gets called on init and gives a something like this? export interface Hooks extends Record<string, HookFn<any[], any>> {
/** Called on init - Publish to all connections */
publisher: (publisher: WSPublisher) => MaybePromise<void>; // <- new hook
/** Upgrading */
upgrade: (req: WSRequest) => MaybePromise<void | { headers?: HeadersInit }>;
/** A message is received */
message: (peer: Peer, message: Message) => MaybePromise<void>;
/** A socket is opened */
open: (peer: Peer) => MaybePromise<void>;
/** A socket is closed */
close: (
peer: Peer,
details: { code?: number; reason?: string },
) => MaybePromise<void>;
/** An error occurs */
error: (peer: Peer, error: WSError) => MaybePromise<void>;
} for for like this: export interface BunAdapter {
websocket: WebSocketHandler<ContextData>;
handleUpgrade(req: Request, server: Server): Promise<boolean>;
setServer(server: Server): void; // <- new part
} this would have to be called after the maybe I also completely misunderstood your comment... |
Describe the feature
As far as I am concerned it is only possible to interact with channels/topics via peers.
It would be very usefull to have a global ws Obj which makes it possible to publish messages without a peer.
example usecase:
Having a chat app where only reviewing works with ws but sending does not.
In this case the HTTP request handle would not have any ws peer but would still need to publish a message.
Additional information
The text was updated successfully, but these errors were encountered: