Removing ws subprotocol; Creating new post-connection update hook
This commit is contained in:
@ -311,23 +311,10 @@ class IrisCore(pykka.ThreadingActor):
|
||||
|
||||
self.connections[client['connection_id']] = {
|
||||
'client': client,
|
||||
'id': client['connection_id'],
|
||||
'connection_id': client['connection_id'],
|
||||
'connection': connection
|
||||
}
|
||||
|
||||
self.send_message(data={
|
||||
'recipient': client['connection_id'],
|
||||
'method': 'connection_established',
|
||||
'params': {
|
||||
'connection': {
|
||||
'connection_id': client['connection_id'],
|
||||
'client_id': client['client_id'],
|
||||
'username': client['username'],
|
||||
'ip': client['ip']
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
self.broadcast(data={
|
||||
'method': 'connection_added',
|
||||
'params': {
|
||||
@ -335,6 +322,40 @@ class IrisCore(pykka.ThreadingActor):
|
||||
}
|
||||
})
|
||||
|
||||
def update_connection(self, *args, **kwargs):
|
||||
callback = kwargs.get('callback', None)
|
||||
data = kwargs.get('data', {})
|
||||
connection_id = data['connection_id']
|
||||
|
||||
if connection_id in self.connections:
|
||||
self.connections[connection_id]['client']['username'] = data['username']
|
||||
self.connections[connection_id]['client']['client_id'] = data['client_id']
|
||||
self.broadcast(data={
|
||||
'method': "connection_changed",
|
||||
'params': {
|
||||
'connection': self.connections[connection_id]['client']
|
||||
}
|
||||
})
|
||||
response = {
|
||||
'connection': self.connections[connection_id]['client']
|
||||
}
|
||||
if (callback):
|
||||
callback(response)
|
||||
else:
|
||||
return response
|
||||
|
||||
else:
|
||||
error = 'Connection "'+data['connection_id']+'" not found'
|
||||
logger.error(error)
|
||||
|
||||
error = {
|
||||
'message': error
|
||||
}
|
||||
if (callback):
|
||||
callback(False, error)
|
||||
else:
|
||||
return error
|
||||
|
||||
def remove_connection(self, connection_id):
|
||||
if connection_id in self.connections:
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user