code: func (rtm *RTM) handleEvents() {
  	ticker := time.NewTicker(rtm.pingInterval)
  	defer ticker.Stop()
  	for {
  		select {
  		// catch "stop" signal on channel close
  		case intentional := <-rtm.killChannel:
  			_ = rtm.killConnection(intentional)
  			return
  		// detect when the connection is dead.
  		case <-rtm.pingDeadman.C:
  			rtm.Debugln("deadman switch trigger disconnecting")
  			_ = rtm.killConnection(false)
  			return
  		// send pings on ticker interval
  		case <-ticker.C:
  			if err := rtm.ping(); err != nil {
  				_ = rtm.killConnection(false)
  				return
  			}
  		case <-rtm.forcePing:
  			if err := rtm.ping(); err != nil {
  				_ = rtm.killConnection(false)
  				return
  			}
  		// listen for messages that need to be sent
  		case msg := <-rtm.outgoingMessages:
  			rtm.sendOutgoingMessage(msg)
  		// listen for incoming messages that need to be parsed
  		case rawEvent := <-rtm.rawEvents:
  			switch rtm.handleRawEvent(rawEvent) {
  			case rtmEventTypeGoodbye:
  				_ = rtm.killConnection(false)
  				return
  			default:
  			}
  		}
  	}
  }
docs: // handleEvents is a blocking function that handles all events. This sends
  // pings when asked to (on rtm.forcePing) and upon every given elapsed
  // interval. This also sends outgoing messages that are received from the RTM's
  // outgoingMessages channel. This also handles incoming raw events from the RTM
  // rawEvents channel.