rocket.chat.mqtt
Version:
It's a MQTT Server, using redis to scale horizontally.
37 lines (24 loc) • 851 B
JavaScript
;
var _rocketChat = require('rocket.chat.proto');
var _publish = require('../Routes/publish');
var _publish2 = _interopRequireDefault(_publish);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const decodeTyping = (0, _rocketChat.decoder)('typing');
const encodeTyping = (0, _rocketChat.encoder)('typing');
_publish2.default.add('notify-room/:rid/typing', (client, packet, { rid }) => {
const { user } = client;
if (!user || !user._id) {
return false;
}
if (!client.subscriptions[`room-messages/${rid}`]) {
return false;
}
const [status, ...args] = decodeTyping(packet.payload);
if (typeof status === typeof true || args.length) {
return false;
}
packet.qos = 0;
packet.retain = false;
packet.payload = encodeTyping({ status, _id: user._id });
return true;
});