npm i install worker-ws-client --save-dev or yarn add worker-ws-client --save-devimport WorkerWsClient from "worker-ws-client"
class WsClient extends WorkerWsClient {
constructor(){
super()
this._worker.addEventListener('message', e => {
})
}
}构建WsWorkerClient实例
通过worker 发送消息
| Param | Type | Description |
|---|---|---|
| message | Object |
{type:string,args:Array} |
| transfer | * |
| Param | Type | Description |
|---|---|---|
| params | Object |
消息类型加参数数据 |
| asyncCallback | Fucntion |
存储回调方法 |
初始化websocket
| Param | Type | Description |
|---|---|---|
| websocketUrl | String |
websocket地址 |