MCPcopy
hub / github.com/wavetermdev/waveterm / unregisterRpc

Method unregisterRpc

pkg/wshutil/wshrpc.go:489–512  ·  view source on GitHub ↗
(reqId string, err error)

Source from the content-addressed store, hash-verified

487}
488
489func (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
515func (w *WshRpc) SendCommand(command string, data any, opts *wshrpc.RpcOpts) error {

Callers 3

runServerMethod · 0.95
finalizeMethod · 0.80

Calls 2

callContextCancelFnMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected