libnmdc: assert state parameter is set correctly
This commit is contained in:
parent
393f156b0e
commit
e111c99886
@ -342,10 +342,14 @@ func (this *HubConnection) worker() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.OnEvent <- HubEvent{EventType: EVENT_CONNECTION_STATE_CHANGED, StateChange: CONNECTIONSTATE_CONNECTING}
|
this.State = CONNECTIONSTATE_DISCONNECTED
|
||||||
this.connValid = false
|
this.connValid = false
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
this.State = CONNECTIONSTATE_CONNECTING
|
||||||
this.connValid = true
|
this.connValid = true
|
||||||
|
this.OnEvent <- HubEvent{EventType: EVENT_CONNECTION_STATE_CHANGED, StateChange: CONNECTIONSTATE_CONNECTING}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -361,7 +365,10 @@ func (this *HubConnection) worker() {
|
|||||||
// Maybe we disconnected
|
// Maybe we disconnected
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.OnEvent <- HubEvent{EventType: EVENT_CONNECTION_STATE_CHANGED, StateChange: CONNECTIONSTATE_DISCONNECTED, Message: err.Error()}
|
this.OnEvent <- HubEvent{EventType: EVENT_CONNECTION_STATE_CHANGED, StateChange: CONNECTIONSTATE_DISCONNECTED, Message: err.Error()}
|
||||||
|
this.State = CONNECTIONSTATE_DISCONNECTED
|
||||||
this.conn = nil
|
this.conn = nil
|
||||||
|
this.connValid = false
|
||||||
|
|
||||||
time.Sleep(30 * time.Second) // Wait before reconnect
|
time.Sleep(30 * time.Second) // Wait before reconnect
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user