kudos/koa-websocket
Tentang
Light wrapper around Koa providing a websocket middleware handler that is koa-route compatible.
Pengembangan web dan aplikasiPertumbuhan bintang terukur
- dalam 24 jam
- 0
- dalam 7 hari
- 0
- dalam 15 hari
- 0
- dalam 1 bulan
- Mengumpulkan riwayat
Perubahan bersih pada periode yang tumpang tindih, bukan total harian. Pengukuran yang belum tersedia dibiarkan kosong. Bintang menunjukkan perhatian, bukan kualitas.
README.md
Aslikoa-websocket
Koa v2 is now the default. For Koa v1 support install with koa-websocket@2 and see the
legacybranch.
Supports ws:// and wss://
Installation
npm install koa-websocket
Usage
See examples directory for a simple implementation.
Let's Encrypt
Example with Let's Encrypt (the Greenlock package):
const Koa = require('koa');
const greenlock = require('greenlock-express');
const websockify = require('koa-websocket');
const le = greenlock.create({
// all your sweet Let's Encrypt options here
});
// the magic happens right here
const app = websockify(new Koa(), wsOptions, le.httpsOptions);
app.ws.use((ctx) => {
// the websocket is added to the context as `ctx.websocket`.
ctx.websocket.on('message', function(message) {
// do something
});
});
app.listen(3000);
API
websockify(KoaApp, [WebSocketOptions], [httpsOptions])
The WebSocket options object just get passed right through to the new WebSocketServer(options) call.
The optional HTTPS options object gets passed right into https.createServer(options). If the HTTPS options are
passed in, koa-websocket will use the built-in Node HTTPS server to provide support for the wss:// protocol.
License
MIT
Jelajahi proyek terkait
Memuat…