_receiveMessage(encoded_message) {
		log_debug(`Radio[${this.radio_id}]._receiveMessage(${encoded_message})`);
		const message = flex.decode(encoded_message);
		if (message) {
			// Update internal data whenever we see an update...
			switch (message.type) {
				case 'status':
					// TODO: Rewrite topic and payload to 'meter/24' or 'meter/NAME'?
					if (message.topic === 'meter') {
						this._updateMeterList(message.payload);
					}
					break;
				case 'handle':
					this._updateClientHandle(message.payload);
					break;
			}

			// Send back to a reuqest or emit as asynchronous event
			if (message.type === MessageTypes.response) {
				const request = this.requests[message.sequence_number];
				if (request && request.callback) {
					request.callback(message);
				} else if (!request) {
					console.error(`Radio[${this.radio_id}]._receiveMessage(${encoded_message}): No matching request!`);
				}
				// Remove request after satisfied
				delete this.requests[message.sequence_number];
			} else {
				this.emit(message.type, message);
			}
		}
	}
// Handles a singluar, separated, message line from TCP/IP stream
Handles a singluar, separated, message line from TCP/IP stream
Handles a singluar separated message line from TCP / IP stream
_receiveMessage(encoded_message) {
		log_debug(`Radio[${this.radio_id}]._receiveMessage(${encoded_message})`);
		const message = flex.decode(encoded_message);
		if (message) {
			switch (message.type) {
				case 'status':
					if (message.topic === 'meter') {
						this._updateMeterList(message.payload);
					}
					break;
				case 'handle':
					this._updateClientHandle(message.payload);
					break;
			}
			if (message.type === MessageTypes.response) {
				const request = this.requests[message.sequence_number];
				if (request && request.callback) {
					request.callback(message);
				} else if (!request) {
					console.error(`Radio[${this.radio_id}]._receiveMessage(${encoded_message}): No matching request!`);
				}
				delete this.requests[message.sequence_number];
			} else {
				this.emit(message.type, message);
			}
		}
	}
_receiveMessage ( encoded_message ) { log_debug ( ` ${ this . radio_id } ${ encoded_message } ` ) ; const message = flex . decode ( encoded_message ) ; if ( message ) { switch ( message . type ) { case 'status' : if ( message . topic === 'meter' ) { this . _updateMeterList ( message . payload ) ; } break ; case 'handle' : this . _updateClientHandle ( message . payload ) ; break ; } if ( message . type === MessageTypes . response ) { const request = this . requests [ message . sequence_number ] ; if ( request && request . callback ) { request . callback ( message ) ; } else if ( ! request ) { console . error ( ` ${ this . radio_id } ${ encoded_message } ` ) ; } delete this . requests [ message . sequence_number ] ; } else { this . emit ( message . type , message ) ; } } }
Handles a singluar, separated, message line from TCP/IP stream
Handles a singluar separated message line from TCP / IP stream
// Update internal data whenever we see an update... // TODO: Rewrite topic and payload to 'meter/24' or 'meter/NAME'? // Send back to a reuqest or emit as asynchronous event // Remove request after satisfied