adc: handle user parts

--HG--
branch : adc
This commit is contained in:
mappu 2017-11-26 17:53:14 +13:00
parent 916874e8bd
commit d392cd379d

View File

@ -229,15 +229,37 @@ func (this *AdcProtocol) ProcessCommand(msg string) {
case "IQUI": case "IQUI":
// Error message from the hub // Error message from the hub
// IQUI V3M6 DI1 MSNick\staken,\splease\spick\sanother\sone TL-1 // IQUI V3M6 DI1 MSNick\staken,\splease\spick\sanother\sone TL-1
flags, err := this.parts2flags(parts[1:]) if len(parts) < 2 {
this.malformed(parts)
return
}
sid := parts[1]
flags, err := this.parts2flags(parts[2:])
if err != nil { if err != nil {
return return
} }
if sid == this.sid {
if msg, ok := flags["MS"]; ok { if msg, ok := flags["MS"]; ok {
this.hc.processEvent(HubEvent{EventType: EVENT_SYSTEM_MESSAGE_FROM_HUB, Message: "The hub is closing our connection because: " + this.unescape(msg)}) this.hc.processEvent(HubEvent{EventType: EVENT_SYSTEM_MESSAGE_FROM_HUB, Message: "The hub is closing our connection because: " + this.unescape(msg)})
} else { } else {
this.hc.processEvent(HubEvent{EventType: EVENT_SYSTEM_MESSAGE_FROM_HUB, Message: "The hub is closing our connection"}) this.hc.processEvent(HubEvent{EventType: EVENT_SYSTEM_MESSAGE_FROM_HUB, Message: "The hub is closing our connection"})
} }
} else {
this.hc.usersMut.Lock()
defer this.hc.usersMut.Unlock()
otherSidNick, ok := this.hc.userSIDs[sid]
if ok {
delete(this.hc.userSIDs, sid)
delete(this.hc.users, otherSidNick)
this.hc.processEvent(HubEvent{EventType: EVENT_USER_PART, Nick: otherSidNick})
} else {
// ??
this.logError(fmt.Errorf("An unknown user quit the hub (SID=%s)", sid))
}
}
case "BMSG": case "BMSG":
// Message from a user // Message from a user