_open (callback) { this[kServer].listen(0, () => { debug('active on port %o', this.port) callback() }) }
/** * send message to app * @param {String} action - message key * @param {Object} data - message value * @return {Messenger} this */ sendToApp(action, data) { debug('[%s] send %s with %j to all app', this.pid, action, data); this.send(action, data, 'app'); return this; }
/** * @param {string} message */ _messageReceived(message) { if (this._handler) { protocolDebug('<', message); this._handler.dispatchMessage(message); } }
_onRemove(filePath) { filePath = slash(filePath); const relativePath = path.relative(this.sourcePath, filePath); if ( relativePath.indexOf("node_modules") !== -1 || relativePath.indexOf("zero-builds") !== -1 ) { return; } debug("[REM]".yellow, filePath); if (this.isWatching) this._emitFileChange("remove", filePath); }
const sendWebPushNotification = ( subscription: any, payload: Object | string, options?: ?Object ): Promise<?Object> => { return sendWebPush(subscription, payload, options).catch(err => { if (err.statusCode === 410 && err.endpoint) { debug(`old subscription found (${err.endpoint}), removing`, err); return removeSubscription(err.endpoint); } }); }
_onMessage(message) { if (message && is.string(message.action)) { debug('[%s] got message %s with %j, receiverPid: %s', this.pid, message.action, message.data, message.receiverPid); this.emit(message.action, message.data); } }
/** * @param {string} message */ send(message) { if (this._ws.readyState === WebSocket.OPEN) { protocolDebug('>', message); this._ws.send(message); } }
const createPayload = (type: EntityTypes, data: Object): Object => debug(`create payload for ${type.toLowerCase()}#${data.id}`) || { type, id: data.id, payload: JSON.stringify(data), }
function _markAsCompleted (db, id) { var completed_at = utils.getCurrentDateTimeAsString() debug('Marking job ID %s as completed at %s', id, completed_at) return db.markAsCompleted(id) }
const removeSubscription = (endpoint: string) => { debug(`remove subscription ${endpoint}`); return db .table('webPushSubscriptions') .getAll(endpoint, { index: 'endpoint' }) .delete() .run(); }
_destroy (reason, cb) { if (reason) debug('destroy %o: %O', this[kTitle], reason) clearTimeout(this[kIdleTimer]) this[kParser].destroy() cb(reason) }
_open (callback) { this[kServer] = this[kApp].listen(0, () => { debug('active on port %o', this.port) callback() }) enableDestroy(this[kServer]) }
/** * send message to agent * @param {String} action - message key * @param {Object} data - message value * @return {Messenger} this */ sendToAgent(action, data) { debug('[%s] send %s with %j to all agent', this.pid, action, data); this.send(action, data, 'agent'); return this; }
/** * Send message to all agent and app * @param {String} action - message key * @param {Object} data - message value * @return {Messenger} this */ broadcast(action, data) { debug('[%s] broadcast %s with %j', this.pid, action, data); this.send(action, data, 'both'); return this; }
/** * send message to app * @param {String} action - message key * @param {Object} data - message value * @return {Messenger} this */ sendToApp(action, data) { debug('[%s] send %s with %j to all app', this.pid, action, data); this.send(action, data, 'application'); return this; }