function _handleMessagePing() {
  _handleMessagePing = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee18(state, msgObj) {
    var messages, useMessages;
    return _regenerator["default"].wrap(function _callee18$(_context18) {
      while (1) switch (_context18.prev = _context18.next) {
        case 0:
          if (state.messagesCallback) {
            _context18.next = 2;
            break;
          }
          return _context18.abrupt("return");
        case 2:
          if (msgObj) {
            _context18.next = 8;
            break;
          }
          _context18.next = 5;
          return getAllMessages(state.channelName, state.paths);
        case 5:
          messages = _context18.sent;
          _context18.next = 9;
          break;
        case 8:
          // get single message
          messages = [getSingleMessage(state.channelName, msgObj, state.paths)];
        case 9:
          useMessages = messages.filter(function (msgObj) {
            return _filterMessage(msgObj, state);
          }).sort(function (msgObjA, msgObjB) {
            return msgObjA.time - msgObjB.time;
          }); // sort by time
          // if no listener or message, so not do anything
          if (!(!useMessages.length || !state.messagesCallback)) {
            _context18.next = 12;
            break;
          }
          return _context18.abrupt("return");
        case 12:
          _context18.next = 14;
          return Promise.all(useMessages.map(function (msgObj) {
            return readMessage(msgObj).then(function (content) {
              return msgObj.content = content;
            });
          }));
        case 14:
          useMessages.forEach(function (msgObj) {
            state.emittedMessagesIds.add(msgObj.token);
            if (state.messagesCallback) {
              // emit to subscribers
              state.messagesCallback(msgObj.content.data);
            }
          });
        case 15:
        case "end":
          return _context18.stop();
      }
    }, _callee18);
  }));
  return _handleMessagePing.apply(this, arguments);
}
ensures that the channelState is connected with all other readers
@return {Promise<void>}