Fix updating of EventManager.CurrentState

The EventManager methods did not use a pointer as receiver, which
caused updated of CurrentState to be lost.
This commit is contained in:
Wichert Akkerman
2019-12-09 12:30:37 +01:00
parent 6a3833b27d
commit f8c992a385
2 changed files with 21 additions and 3 deletions
+3 -3
View File
@@ -60,21 +60,21 @@ type EventManager struct {
Handler EventHandler
}
func (em EventManager) updateState(state ConnState) {
func (em *EventManager) updateState(state ConnState) {
em.CurrentState = state
if em.Handler != nil {
em.Handler(Event{State: em.CurrentState})
}
}
func (em EventManager) disconnected(state SMState) {
func (em *EventManager) disconnected(state SMState) {
em.CurrentState = StateDisconnected
if em.Handler != nil {
em.Handler(Event{State: em.CurrentState, SMState: state})
}
}
func (em EventManager) streamError(error, desc string) {
func (em *EventManager) streamError(error, desc string) {
em.CurrentState = StateStreamError
if em.Handler != nil {
em.Handler(Event{State: em.CurrentState, StreamError: error, Description: desc})