mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-06 20:46:50 +08:00
15 lines
320 B
TypeScript
15 lines
320 B
TypeScript
import Koa = require('koa');
|
|
import websocket = require('koa-websocket');
|
|
|
|
const app = websocket(new Koa());
|
|
|
|
app.ws.use(async function(context, next) {
|
|
this.websocket.on('message', (message) => {
|
|
console.log(message);
|
|
});
|
|
this.websocket.send('Hello world');
|
|
await next();
|
|
});
|
|
|
|
app.listen(3000);
|