Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return (store) => (next) => (action) => {
switch (action.type) {
case 'MOPIDY_CONNECT':
if (socket != null) {
socket.close();
}
store.dispatch({ type: 'MOPIDY_CONNECTING' });
var state = store.getState();
socket = new Mopidy({
webSocketUrl: `ws${window.location.protocol === 'https:' ? 's' : ''}://${state.mopidy.host}:${state.mopidy.port}/mopidy/ws/`,
callingConvention: 'by-position-or-by-name',
});
socket.on((type, data) => handleMessage(socket, store, type, data));
break;
case 'MOPIDY_CONNECTED':
if (store.getState().ui.allow_reporting) {
ReactGA.event({
category: 'Mopidy',
action: 'Connected',
label: sha256(window.location.hostname),
});
}
next(action);
constructor( props ){
super(props)
this.connection = new Mopidy({
webSocketUrl: "ws://music.james:6680/mopidy/ws",
callingConvention: 'by-position-or-by-name'
});
this.connection.on( (type, data) => this.handleMessage( type, data ) );
}