Plugin: no response to websocket emit(play)

Hello…

I’m experimenting with a plugin on similar lines to gpio-buttons, but to respond to events from a touch enabled i2c sensor.

My plugin can quite happily detect the touch events, but I’m struggling to get these connected to say ‘play’. the code is very similar to gpio-buttons.

			self.logger.info("Emitting state")
			socket.emit('getState', '');
			socket.once('pushState', function (state) {
				console.log(state)
				if (state.status == 'play' && state.service == 'webradio') {
					socket.emit('stop');
				} else if (state.status == 'play') {
					socket.emit('pause');
				} else {
					socket.emit('play');
				}
			});

But I get no response to the ‘getstate’ and the ‘play’ is never honoured. Where as gpio-buttons works just fine.

(my code is currently at https://github.com/mbwhite/volumio-plugins-sources/blob/1caf675463b5b122d0e75c140277f65bdf5b2fbd/touch_buttons/index.js#L49)

Sure I’m missing something obvious!

Cheers Matthew

I’ve been able to solve this problem.

The websocket library I was using in my plugin was the latest v4 - whereas volumio itself is on v1.4 (nearly 8 years old!)

Swapping to the older library makes things work!