(reqId string, err error)
| 487 | } |
| 488 | |
| 489 | func (w *WshRpc) unregisterRpc(reqId string, err error) { |
| 490 | w.Lock.Lock() |
| 491 | defer w.Lock.Unlock() |
| 492 | rd := w.RpcMap[reqId] |
| 493 | if rd == nil { |
| 494 | return |
| 495 | } |
| 496 | if err != nil { |
| 497 | errResp := &RpcMessage{ |
| 498 | ResId: reqId, |
| 499 | Error: err.Error(), |
| 500 | } |
| 501 | // non-blocking send since we're about to close anyway |
| 502 | // likely the channel isn't being actively read |
| 503 | // this also prevents us from blocking the main loop (and holding the lock) |
| 504 | select { |
| 505 | case rd.ResCh <- errResp: |
| 506 | default: |
| 507 | } |
| 508 | } |
| 509 | delete(w.RpcMap, reqId) |
| 510 | close(rd.ResCh) |
| 511 | rd.Handler.callContextCancelFn() |
| 512 | } |
| 513 | |
| 514 | // no response |
| 515 | func (w *WshRpc) SendCommand(command string, data any, opts *wshrpc.RpcOpts) error { |
no test coverage detected