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.BROADCASTto ‘-broadcast’djangofloor.tasks.WINDOWto ‘-window.’ + the unique window key provided by thedjangofloor.wsgi.window_info.WindowInfoobject,django.db.models.Modelas “app_label.model_name.primary_key”djangofloor.tasks.USERto converted to the authenticated user then serialized as any Django model,django.wsgi.window_info.Sessionserialized to “-session.key”- other objects are serialized to “class.hash(obj)”