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

Method handleNoRoute

pkg/wshutil/wshrouter.go:220–249  ·  view source on GitHub ↗
(msg RpcMessage, ingressLinkId baseds.LinkId)

Source from the content-addressed store, hash-verified

218}
219
220func (router *WshRouter) handleNoRoute(msg RpcMessage, ingressLinkId baseds.LinkId) {
221 lm := router.getLinkMeta(ingressLinkId)
222 if lm == nil {
223 return
224 }
225 nrErr := noRouteErr(msg.Route)
226 if msg.ReqId == "" {
227 if msg.Command == wshrpc.Command_Message {
228 // to prevent infinite loops
229 return
230 }
231 // no response needed, but send message back to source
232 respMsg := RpcMessage{
233 Command: wshrpc.Command_Message,
234 Route: msg.Source,
235 Source: ControlRoute,
236 Data: wshrpc.CommandMessageData{Message: nrErr.Error()},
237 }
238 respBytes, _ := json.Marshal(respMsg)
239 router.sendRpcMessageToLink(lm.linkId, lm.client, respBytes, baseds.NoLinkId, "no-route-err")
240 return
241 }
242 // send error response
243 response := RpcMessage{
244 ResId: msg.ReqId,
245 Error: nrErr.Error(),
246 }
247 respBytes, _ := json.Marshal(response)
248 router.sendRoutedMessage(respBytes, msg.Source, msg.Command, baseds.NoLinkId)
249}
250
251func (router *WshRouter) registerRouteInfo(rpcId string, sourceLinkId baseds.LinkId, destRouteId string) {
252 if rpcId == "" {

Callers 1

runServerMethod · 0.95

Calls 5

getLinkMetaMethod · 0.95
sendRpcMessageToLinkMethod · 0.95
sendRoutedMessageMethod · 0.95
noRouteErrFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected