(seq_id, msg, callback=undefined)
| 50 | }; |
| 51 | |
| 52 | const send = (seq_id, msg, callback=undefined) => { |
| 53 | msg.ty = 'request'; |
| 54 | if (seq_id >= 0) |
| 55 | msg.seq_id = seq_id; |
| 56 | else { |
| 57 | msg.seq_id = seq; |
| 58 | setSeq(seq + 1); |
| 59 | } |
| 60 | let tmp = registry; |
| 61 | if (!(msg.seq_id in tmp)) { |
| 62 | tmp[msg.seq_id] = [] |
| 63 | } |
| 64 | if (callback) { |
| 65 | tmp[msg.seq_id].push(callback) |
| 66 | } |
| 67 | setRegistry(tmp); |
| 68 | ws.current && ws.current.send(JSON.stringify(msg)); |
| 69 | return msg.seq_id; |
| 70 | }; |
| 71 | |
| 72 | useEffect(() => { |
| 73 | return () => { |
no test coverage detected