【文件属性】:
文件名称:koa-easy-ws:用于Websocket处理的简单Koa中间件
文件大小:46KB
文件格式:ZIP
更新时间:2021-05-02 09:23:46
JavaScript
简单,易用,可组合的中间件,用于Koa中的Websocket处理
用法
const Koa = require ( 'koa' )
const websocket = require ( 'koa-easy-ws' )
const app = new Koa ( )
app . use ( websocket ( ) )
app . use ( async ( ctx , next ) => {
// check if the current request is websocket
if ( ctx . ws ) {
const ws = await ctx . ws ( ) // retrieve socket
// now you have a ws instance, you can use it as you see fit
return ws .
【文件预览】:
koa-easy-ws-master
----LICENSE(1KB)
----test()
--------exposed.js(1KB)
--------renamed.js(2KB)
--------simple.js(2KB)
--------router.js(2KB)
----README.md(5KB)
----index.d.ts(558B)
----.gitignore(914B)
----index.js(2KB)
----package-lock.json(145KB)
----package.json(1000B)