MCPcopy
hub / github.com/aceld/zinx / AddRouter

Method AddRouter

znet/msghandler.go:354–365  ·  view source on GitHub ↗

AddRouter adds specific processing logic for messages (为消息添加具体的处理逻辑)

(msgID uint32, router ziface.IRouter)

Source from the content-addressed store, hash-verified

352// AddRouter adds specific processing logic for messages
353// (为消息添加具体的处理逻辑)
354func (mh *MsgHandle) AddRouter(msgID uint32, router ziface.IRouter) {
355 // 1. Check whether the current API processing method bound to the msgID already exists
356 // (判断当前msg绑定的API处理方法是否已经存在)
357 if _, ok := mh.Apis[msgID]; ok {
358 msgErr := fmt.Sprintf("repeated api , msgID = %+v\n", msgID)
359 panic(msgErr)
360 }
361 // 2. Add the binding relationship between msg and API
362 // (添加msg与api的绑定关系)
363 mh.Apis[msgID] = router
364 zlog.Ins().InfoF("Add Router msgID = %d", msgID)
365}
366
367// AddRouterSlices adds router handlers using slices
368// (切片路由添加)

Callers

nothing calls this directly

Calls 2

InsFunction · 0.92
InfoFMethod · 0.65

Tested by

no test coverage detected