Files
notify/client_dispatcher.go
T

51 lines
1008 B
Go
Raw Permalink Normal View History

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)
}
c.linkMu.RLock()
fn, ok := c.linkFns[message.Key]
defaultFn := c.defaultFns
c.linkMu.RUnlock()
if ok && fn != nil {
callFn(fn)
}
if defaultFn != nil {
callFn(defaultFn)
}
}
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)
}
}