Skip to content

Instantly share code, notes, and snippets.

@madprops
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save madprops/10a2bd3a93334d82bf8f to your computer and use it in GitHub Desktop.
Save madprops/10a2bd3a93334d82bf8f to your computer and use it in GitHub Desktop.
I have this in settings.py:
OMNIBUS_CONNECTION_FACTORY = 'server.views.connection_factory'
OMNIBUS_AUTHENTICATOR_FACTORY = 'omnibus.factories.userauthenticator_factory'
I have this in views.py
def connection_factory(auth_class, pubsub):
class GeneratedConnection(websocket_connection_factory(auth_class, pubsub)):
def open_connection(self):
log(self.authenticator)
return super(GeneratedConnection, self).open_connection()
def close_connection(self):
return super(GeneratedConnection, self).close_connection()
def command_subscribe(self, args):
return super(GeneratedConnection, self).command_subscribe(args)
return GeneratedConnection
I have this in a js file:
function create_omnibus(endpoint, auth)
{
console.log(auth)
var options =
{
authToken: auth
}
return new Omnibus(WebSocket, endpoint, options)
}
this is what I'm getting for the auth token:
2:09310427bc3b59b5524be6a57225475afee459ae
Basically what I need is a way to know which django users are connected on a certain room.
So I was planning on using the overriden connection functions to log in redis or something when a user connects and leaves as well as the room name, so I can have a list of users per room.
The problem with this approach I'm trying is that I can't get the user instance/name:
def open_connection(self):
log(self.authenticator)
return super(GeneratedConnection, self).open_connection()
That log returns False
I'm going to need the room name as well.
Also maybe there's an easier way? I'm not even sure if I can get that information from the connection factory methods.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment