Skip to content

Commit

Permalink
docs(nuxt): update example with latest version
Browse files Browse the repository at this point in the history
Related: #5208

[skip ci]
  • Loading branch information
darrachequesne committed Oct 23, 2024
1 parent ca9e994 commit 4ca6ddb
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions examples/nuxt-example/server/plugins/socket.io.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,18 @@ export default defineNitroPlugin((nitroApp: NitroApp) => {
},
websocket: {
open(peer) {
const nodeContext = peer.ctx.node;
const req = nodeContext.req;
// crossws >= 0.3.0
// @ts-expect-error private method and property
engine.prepare(peer._internal.nodeReq);
// @ts-expect-error private method and property
engine.onWebSocket(peer._internal.nodeReq, peer._internal.nodeReq.socket, peer.websocket);

// @ts-expect-error private method
engine.prepare(req);

const rawSocket = nodeContext.req.socket;
const websocket = nodeContext.ws;

// @ts-expect-error private method
engine.onWebSocket(req, rawSocket, websocket);
// crossws < 0.3.0
// const context = peer.ctx.node;
// // @ts-expect-error private method
// engine.prepare(context.req);
// // @ts-expect-error private method
// engine.onWebSocket(context.req, context.req.socket, context.ws);
}
}
}));
Expand Down

0 comments on commit 4ca6ddb

Please sign in to comment.