-
Notifications
You must be signed in to change notification settings - Fork 81
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
WebSockets support #5
Comments
I am working with the nitro team on this. We already enabled websocket support for the dev server using @vinxi/listhen, a temporary fork of listhen that enables websocket support until unjs/listhen#128 lands. We will then try to land APIs for |
Now that the referenced PR is closed, is there any place to track the progress on WS support, h3/nitro API, etc.? |
So looks like |
I guess the important part that is missing, is the hook to listen for the |
released in 0.3.6 |
Thanks a lot! Is there a tracking issue for bringing this into start? |
Its immediately available in start. Set You can then add a new router to your vinxi app, like this: import { defineConfig } from "@solidjs/start/config";
const app = defineConfig({
server: {
experimental: {
websocket: true,
},
},
});
app.addRouter({
name: "websocket",
type: "http",
handler: "./src/websocket.ts",
target: "server",
base: "/_ws",
});
export default app;
import { defineWebSocket, eventHandler } from "vinxi/http";
export default eventHandler({
handler: () => {},
websocket: defineWebSocket({
async open(event) {
console.log("WebSocket opened");
},
async message(peer, event) {
console.log("WebSocket message", event);
peer.send("YOOO");
},
async close(event) {
console.log("WebSocket closed 3");
},
}),
}); To connect to the websocket try, const ws = new WebSocket('ws://localhost:3000/_ws') |
Is there a way to import defineWebSocket({
upgrade: (req: WSRequest) => MaybePromise<void | { headers?: HeadersInit }>;
message: (peer: Peer, message: Message) => MaybePromise<void>;
open: (peer: Peer) => MaybePromise<void>;
close: (peer: Peer, details: { code?: number; reason?: string }) => MaybePromise<void>;
error: (peer: Peer, error: WSError) => MaybePromise<void>;
}) |
Maybe it should look something like this: solidjs/solid-start#1384 |
I'm currently using websockets in solid-start (although it needed some modifications to the source). Will there be a way to upgrade http connections to websockets in Vinxi?
It does not seem to be support for this in Nitro nitrojs/nitro#678
The text was updated successfully, but these errors were encountered: