Long-running socket watcher, needs proper cleanup

This commit is contained in:
James Barnsley
2018-11-04 14:41:08 +13:00
parent 4327771b2e
commit ffaef9d63e
8 changed files with 156 additions and 44 deletions

View File

@ -21083,6 +21083,7 @@ exports.deleteClient = deleteClient;
exports.setGroupStream = setGroupStream;
exports.setGroupMute = setGroupMute;
exports.setGroupVolume = setGroupVolume;
exports.eventReceived = eventReceived;
exports.serverLoaded = serverLoaded;
exports.clientLoaded = clientLoaded;
exports.clientsLoaded = clientsLoaded;
@ -21170,6 +21171,14 @@ function setGroupVolume(id, percent) {
};
}
function eventReceived(message) {
return {
type: 'SNAPCAST_EVENT_RECEIVED',
method: message.method,
params: message.params
};
}
/**
* Record loaders
*
@ -54274,6 +54283,7 @@ var pusherActions = __webpack_require__(14);
var lastfmActions = __webpack_require__(21);
var geniusActions = __webpack_require__(41);
var spotifyActions = __webpack_require__(8);
var snapcastActions = __webpack_require__(46);
var PusherMiddleware = function () {
var _this = this;
@ -54417,6 +54427,11 @@ var PusherMiddleware = function () {
store.dispatch(uiActions.createNotification({ type: 'bad', content: 'Test failed' }));
break;
}
// Pass snapcast events to the Snapcast service
if (message.method.startsWith('snapcast_')) {
store.dispatch(snapcastActions.eventReceived(message));
}
}
}
};
@ -61102,6 +61117,39 @@ var SnapcastMiddleware = function () {
break;
case 'SNAPCAST_EVENT_RECEIVED':
console.log(action);
// Drop the prefix
action.method = action.method.replace('snapcast_', '');
switch (action.method) {
case 'Client.OnVolumeChanged':
store.dispatch(snapcastActions.clientLoaded({
id: action.params.id,
mute: action.params.volume.muted,
volume: action.params.volume.percent
}));
break;
case 'Client.OnLatencyChanged':
store.dispatch(snapcastActions.clientLoaded({
id: action.params.id,
latency: action.params.latency
}));
break;
case 'Client.OnNameChanged':
store.dispatch(snapcastActions.clientLoaded({
id: action.params.id,
name: action.params.name
}));
break;
}
break;
// This action is irrelevant to us, pass it on to the next middleware
default:
return next(action);