code: func (ed *Dispatcher) HandleDisconnectedEvent(e esdispatcher.Event) {
  	evt := e.(*DisconnectedEvent)
  
  	logger.Debugf("Disconnecting from event server: %s", evt.Err)
  
  	if ed.connection != nil {
  		ed.connection.Close()
  		ed.connection = nil
  	}
  
  	if ed.connectionRegistration != nil {
  		logger.Debugf("Disconnected from event server: %s", evt.Err)
  		select {
  		case ed.connectionRegistration.Eventch <- NewConnectionEvent(false, evt.Err):
  		default:
  			logger.Warn("Unable to send to connection event channel.")
  		}
  	} else {
  		logger.Warnf("Disconnected from event server: %s", evt.Err)
  	}
  
  	if ed.peerMonitorDone != nil {
  		close(ed.peerMonitorDone)
  		ed.peerMonitorDone = nil
  	}
  }
docs: // HandleDisconnectedEvent sends a 'disconnected' event to any registered listener