libnmdc: ensure we always flush protocol commands that happened alongside a disconnection event
This commit is contained in:
parent
debc14cea3
commit
019f67a7de
@ -375,17 +375,6 @@ func (this *HubConnection) worker() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Maybe we disconnected
|
|
||||||
if err != nil {
|
|
||||||
this.State = CONNECTIONSTATE_DISCONNECTED
|
|
||||||
this.conn = nil
|
|
||||||
this.connValid = false
|
|
||||||
this.processEvent(HubEvent{EventType: EVENT_CONNECTION_STATE_CHANGED, StateChange: CONNECTIONSTATE_DISCONNECTED, Message: err.Error()})
|
|
||||||
|
|
||||||
time.Sleep(30 * time.Second) // Wait before reconnect
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
// Attempt to parse a message block
|
// Attempt to parse a message block
|
||||||
for len(fullBuffer) > 0 {
|
for len(fullBuffer) > 0 {
|
||||||
for len(fullBuffer) > 0 && fullBuffer[0] == '|' {
|
for len(fullBuffer) > 0 && fullBuffer[0] == '|' {
|
||||||
@ -400,6 +389,19 @@ func (this *HubConnection) worker() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Maybe we disconnected
|
||||||
|
// Perform this check *last*, to ensure we've had a final shot at
|
||||||
|
// clearing out any queued messages
|
||||||
|
if err != nil {
|
||||||
|
this.State = CONNECTIONSTATE_DISCONNECTED
|
||||||
|
this.conn = nil
|
||||||
|
this.connValid = false
|
||||||
|
this.processEvent(HubEvent{EventType: EVENT_CONNECTION_STATE_CHANGED, StateChange: CONNECTIONSTATE_DISCONNECTED, Message: err.Error()})
|
||||||
|
|
||||||
|
time.Sleep(30 * time.Second) // Wait before reconnect
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user