djangofloor.wsgi.topics
¶
Convert a websocket topic to a string¶
Each webpage using websockets is connected to several topics. Other websocket topics can be any Python object that will be serialized to a string. Two topics are transparently automatically added: BROADCAST and WINDOW. The default serializer should be sufficient for any Django models, but of course you can override it with the WEBSOCKET_TOPIC_SERIALIZER setting.
-
djangofloor.wsgi.topics.
serialize_topic
(window_info, obj)[source]¶ The default serialization function can serialize any Python object with the following rules
djangofloor.tasks.BROADCAST
to ‘-broadcast’djangofloor.tasks.WINDOW
to ‘-window.’ + the unique window key provided by thedjangofloor.wsgi.window_info.WindowInfo
object,django.db.models.Model
as “app_label.model_name.primary_key”djangofloor.tasks.USER
to converted to the authenticated user then serialized as any Django model,django.wsgi.window_info.Session
serialized to “-session.key”- other objects are serialized to “class.hash(obj)”