(msg RpcMessage, ingressLinkId baseds.LinkId)
| 218 | } |
| 219 | |
| 220 | func (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 | |
| 251 | func (router *WshRouter) registerRouteInfo(rpcId string, sourceLinkId baseds.LinkId, destRouteId string) { |
| 252 | if rpcId == "" { |
no test coverage detected