libnmdc: set our own state before emitting statechange event

This commit is contained in:
mappu 2016-04-03 18:38:06 +12:00
parent 4499c7306d
commit 99e4ebb842

View File

@ -366,10 +366,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.State = CONNECTIONSTATE_DISCONNECTED this.State = CONNECTIONSTATE_DISCONNECTED
this.conn = nil this.conn = nil
this.connValid = false this.connValid = false
this.OnEvent <- HubEvent{EventType: EVENT_CONNECTION_STATE_CHANGED, StateChange: CONNECTIONSTATE_DISCONNECTED, Message: err.Error()}
time.Sleep(30 * time.Second) // Wait before reconnect time.Sleep(30 * time.Second) // Wait before reconnect
continue continue