【文件属性】:
文件名称:sockette:最可爱的WebSocket包装器! :socks:
文件大小:30KB
文件格式:ZIP
更新时间:2021-02-21 10:43:18
JavaScript
索克特
最可爱的WebSocket包装器! :socks:
Sockette是围绕WebSocket一个很小的包装器(367字节),如果连接断开,它将自动重新连接!
除了附加,Sockette还允许您重用实例,而无需重新声明所有事件侦听器。
您可以直接通过每个EventListener回调访问(当前)基础WebSocket (通过event.target )。
安装
$ npm install --save sockette
用法
与WebSocket不同,您应该在初始化时声明所有事件侦听器:
const Sockette = require ( 'sockette' ) ;
const ws = new Sockette ( 'ws://localhost:3000' , {
timeout : 5e3 ,
maxAttempts : 10 ,
onopen : e => c
【文件预览】:
sockette-master
----.gitignore(41B)
----package.json(696B)
----src()
--------index.js(1KB)
----sockette.d.ts(697B)
----.github()
--------FUNDING.yml(14B)
--------workflows()
----sockette.jpg(27KB)
----license(1KB)
----readme.md(5KB)
----test()
--------index.js(146B)
----.editorconfig(211B)