Skip to content

Commit

Permalink
Fixing username
Browse files Browse the repository at this point in the history
  • Loading branch information
jaedb committed Jan 9, 2017
1 parent 0709786 commit bebf968
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions mopidy_iris/pusher.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def open(self):
logger.info( 'Pusher connection established: '+ connectionid +' ('+ clientid +'/'+ username +')' )

# broadcast to all connections that a new user has connected
broadcast( 'client_connected', client )
broadcast( 'new_connection', client )

def select_subprotocol(self, subprotocols):
# select one of our subprotocol elements and return it. This confirms the connection has been accepted.
Expand Down Expand Up @@ -217,7 +217,7 @@ def on_message(self, message):
)

# notify all clients of this change
broadcast( 'connection_updated', { 'connections': connections[messageJson['origin']['connectionid']]['client'] })
broadcast( 'connection_updated', { 'connection': connections[messageJson['origin']['connectionid']]['client'] })

# start radio
elif messageJson['action'] == 'start_radio':
Expand Down
14 changes: 7 additions & 7 deletions src/js/services/pusher/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,17 @@ const PusherMiddleware = (function(){
request({ action: 'get_version' })
.then(
response => {
store.dispatch({ type: 'PUSHER_VERSION', data: response.data })
store.dispatch({ type: 'VERSION', data: response.data })
}
)
return next(action);
break;

case 'PUSHER_UPGRADING':
case 'UPGRADING':
request({ action: 'perform_upgrade' })
.then(
response => {
store.dispatch({ type: 'PUSHER_UPGRADE', data: response.data })
store.dispatch({ type: 'UPGRADE', data: response.data })
}
)
return next(action);
Expand All @@ -139,19 +139,19 @@ const PusherMiddleware = (function(){
case 'PUSHER_SET_USERNAME':
request({ action: 'set_username', username: action.username })
.then(
response => {
response => {
store.dispatch({ type: 'PUSHER_USERNAME', data: { username: response.data.username }})
}
)
return next(action);
break;

case 'PUSHER_GET_CONNECTIONS':
case 'PUSHER_CLIENT_CONNECTED':
case 'GET_CONNECTIONS':
case 'NEW_CONNECTION':
request({ action: 'get_connections' })
.then(
response => {
store.dispatch({ type: 'PUSHER_CONNECTIONS', data: response.data })
store.dispatch({ type: 'CONNECTIONS', data: response.data })
}
)
return next(action);
Expand Down
12 changes: 6 additions & 6 deletions src/js/services/pusher/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,27 @@ export default function reducer(pusher = {}, action){
case 'PUSHER_USERNAME':
return Object.assign({}, pusher, { username: action.data.username });

case 'PUSHER_CONNECTIONS':
case 'CONNECTIONS':
return Object.assign({}, pusher, { connections: action.data.connections });

case 'PUSHER_CONNECTION_UPDATED':
case 'CONNECTION_UPDATED':
function byID(connection){
return connection.connectionid == action.data.connections.connectionid;
return connection.connectionid == action.data.connection.connectionid;
}
var connection = pusher.connections.find(byID);
var index = pusher.connections.indexOf(connection);
var connections = Object.assign([], pusher.connections);
connections[index] = action.data.connections;
connections[index] = action.data.connection;

return Object.assign({}, pusher, { connections: connections });

case 'PUSHER_VERSION':
case 'VERSION':
return Object.assign({}, pusher, {
version: action.data.version,
upgrading: false
});

case 'PUSHER_UPGRADING':
case 'UPGRADING':
return Object.assign({}, pusher, { upgrading: true });

default:
Expand Down

0 comments on commit bebf968

Please sign in to comment.