2026-04-15 15:24:36 +08:00
|
|
|
package notify
|
|
|
|
|
|
|
|
|
|
func (c *ClientCommon) dispatchMsg(message Message) {
|
|
|
|
|
switch message.TransferMsg.Type {
|
|
|
|
|
case MSG_SYS_WAIT:
|
|
|
|
|
fallthrough
|
|
|
|
|
case MSG_SYS:
|
|
|
|
|
c.sysMsg(message)
|
|
|
|
|
return
|
|
|
|
|
case MSG_KEY_CHANGE:
|
|
|
|
|
fallthrough
|
|
|
|
|
case MSG_SYS_REPLY:
|
|
|
|
|
fallthrough
|
|
|
|
|
case MSG_SYNC_REPLY:
|
|
|
|
|
if c.getPendingWaitPool().deliver(message.ID, message) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
fallthrough
|
|
|
|
|
default:
|
|
|
|
|
}
|
|
|
|
|
if c.dispatchInternalTransferControl(message) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
callFn := func(fn func(*Message)) {
|
|
|
|
|
fn(&message)
|
|
|
|
|
}
|
2026-08-14 10:16:37 +08:00
|
|
|
c.linkMu.RLock()
|
2026-04-15 15:24:36 +08:00
|
|
|
fn, ok := c.linkFns[message.Key]
|
2026-08-14 10:16:37 +08:00
|
|
|
defaultFn := c.defaultFns
|
|
|
|
|
c.linkMu.RUnlock()
|
|
|
|
|
if ok && fn != nil {
|
2026-04-15 15:24:36 +08:00
|
|
|
callFn(fn)
|
|
|
|
|
}
|
2026-08-14 10:16:37 +08:00
|
|
|
if defaultFn != nil {
|
|
|
|
|
callFn(defaultFn)
|
2026-04-15 15:24:36 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *ClientCommon) sysMsg(message Message) {
|
|
|
|
|
switch message.Key {
|
|
|
|
|
case "bye":
|
|
|
|
|
if message.TransferMsg.Type == MSG_SYS_WAIT {
|
|
|
|
|
c.setByeFromServer(true)
|
|
|
|
|
message.Reply(nil)
|
|
|
|
|
c.stopClientSession("recv stop signal from server", nil)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
c.stopClientSessionFromServer("recv stop signal from server", nil)
|
|
|
|
|
}
|
|
|
|
|
}
|