diff --git a/mopidy_iris/core.py b/mopidy_iris/core.py index d83e166c..15e3cdd3 100755 --- a/mopidy_iris/core.py +++ b/mopidy_iris/core.py @@ -29,10 +29,6 @@ class IrisCore(object): } - def on_start(self): - logger.info('--- Starting Iris core '+self.version) - - ## # Generate a random string # @@ -83,7 +79,7 @@ class IrisCore(object): for connection in self.connections.itervalues(): connection['connection'].write_message( json_encode(data) ) return { - 'status': 'ok', + 'status': 1, 'message': 'Broadcast to '+str(len(self.connections))+' connections' } @@ -101,6 +97,7 @@ class IrisCore(object): connections.append(connection['client']) return { + 'status': 1, 'connections': connections } @@ -145,7 +142,7 @@ class IrisCore(object): 'connection': self.connections[connection_id]['client'] }) return { - 'type': 'username_changed', + 'status': 1, 'username': data['username'] } @@ -153,8 +150,27 @@ class IrisCore(object): error = 'Connection "'+data['connection_id']+'" not found' logger.error(error) return { - 'error': error - } + 'status': 0, + 'message': error + } + + def deliver_message(self, data): + to = data['to'] + if to in self.connections: + + self.send_message(to, data['message']) + + return { + 'status': 1 + } + + else: + error = 'Connection "'+data['connection_id']+'" not found' + logger.error(error) + return { + 'status': 0, + 'message': error + } @@ -194,6 +210,7 @@ class IrisCore(object): upgrade_available = False return { + 'status': 1, 'version': { 'current': self.version, 'latest': latest_version, @@ -223,6 +240,7 @@ class IrisCore(object): def get_radio(self, data): return { + 'status': 1, 'radio': self.radio } @@ -235,7 +253,8 @@ class IrisCore(object): # no uris means we can't play radio if not uris: return { - 'error': 'No recommendations found' + 'status': 0, + 'message': 'No recommendations found' } # if we got recommendations @@ -268,7 +287,9 @@ class IrisCore(object): 'radio': self.radio }) - return {} + return { + 'status': 1 + } def load_more_tracks( self ): @@ -327,6 +348,7 @@ class IrisCore(object): def get_queue_metadata(self, data): return { + 'status': 1, 'queue_metadata': self.queue_metadata } @@ -345,7 +367,9 @@ class IrisCore(object): 'queue_metadata': self.queue_metadata }) - return {} + return { + 'status': 1 + } def clean_queue_metadata( self ): cleaned_queue_metadata = {} @@ -363,7 +387,9 @@ class IrisCore(object): 'queue_metadata': self.queue_metadata }) - return {} + return { + 'status': 1 + } ## diff --git a/src/js/components/Modal/SendAuthorizationModal.js b/src/js/components/Modal/SendAuthorizationModal.js index 7950f3ad..0031f864 100755 --- a/src/js/components/Modal/SendAuthorizationModal.js +++ b/src/js/components/Modal/SendAuthorizationModal.js @@ -15,27 +15,34 @@ class SendAuthorizationModal extends React.Component{ super(props) } - handleClick(e, connectionid){ + handleClick(e, connection_id){ e.preventDefault() - this.props.pusherActions.sendAuthorization( connectionid, this.props.authorization, this.props.me ) + this.props.pusherActions.sendAuthorization( connection_id, this.props.authorization, this.props.me ) this.props.uiActions.closeModal() return false; } render(){ + var connections = [] + for (var connection_id in this.props.connections){ + if (this.props.connections.hasOwnProperty(connection_id)) { + connections.push(this.props.connections[connection_id]) + } + } + return (