client/events.go
func (e *EventListener) Disconnect() {
	if e.disconnected {
		return
	}

	// Handle locking
	e.r.eventListenersLock.Lock()
	defer e.r.eventListenersLock.Unlock()

	// Locate and remove it from the global list
	for i, listener := range e.r.eventListeners {
		if listener == e {
			copy(e.r.eventListeners[i:], e.r.eventListeners[i+1:])
			e.r.eventListeners[len(e.r.eventListeners)-1] = nil
			e.r.eventListeners = e.r.eventListeners[:len(e.r.eventListeners)-1]
			break
		}
	}

	// Turn off the handler
	e.err = nil
	e.disconnected = true
	close(e.chActive)
}
func (e *EventListener) Disconnect() {
	if e.disconnected {
		return
	}

	// Handle locking
	e.r.eventListenersLock.Lock()
	defer e.r.eventListenersLock.Unlock()

	// Locate and remove it from the global list
	for i, listener := range e.r.eventListeners {
		if listener == e {
			copy(e.r.eventListeners[i:], e.r.eventListeners[i+1:])
			e.r.eventListeners[len(e.r.eventListeners)-1] = nil
			e.r.eventListeners = e.r.eventListeners[:len(e.r.eventListeners)-1]
			break
		}
	}

	// Turn off the handler
	e.err = nil
	e.disconnected = true
	close(e.chActive)
}
// Disconnect must be used once done listening for events