-
Notifications
You must be signed in to change notification settings - Fork 407
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
Can anyone get koa-websocket to work with koa-router@7.0.1? #281
Comments
bump |
I ran into this too. I haven't had a chance to dig into it yet but switching to |
Can you paste an example of how you worked around this? |
@chovy I adapted this example from the const koa = require('koa'),
route = require('koa-route'),
websockify = require('koa-websocket');
const app = websockify(koa());
// Note it's app.ws.use and not app.use
app.ws.use(route.all('/test/:id', function* (next) {
// `this` is the regular koa context created from the `ws` onConnection `socket.upgradeReq` object.
// the websocket is added to the context on `this.websocket`.
this.websocket.send('Hello World');
this.websocket.on('message', function(message) {
// do something with the message from client
console.log(message);
});
// yielding `next` will pass the context (this) on to the next ws middleware
yield next;
}));
app.listen(3000); That uses So it was just pin-pointing that My test code is on an uncommitted branch that I can't access right now but I can post a better example this evening (PST). |
oh, it uses generators not async/await? that sucks. |
Is |
I opened a PR over at koa-websocket for a |
@cymen nice! Great stuff. Closing this comment as it can be tracked at kudos/koa-websocket#14 or kudos/koa-websocket#18 |
koa-websocket works fine with koa-router@5.x but not 7.
kudos/koa-websocket#14
If anyone can point me in the right direction of how to fix this library I can create a PR.
I think it has to do with this line but I'm not sure how to fix it for 7.x
https://github.com/kudos/koa-websocket/blob/master/index.js#L27
The text was updated successfully, but these errors were encountered: