xia_broadcast.broadcast.Broadcaster

class xia_broadcast.broadcast.Broadcaster

Bases: object

Broadcasting document into subscribers (via websocket)

__init__()

Methods

__init__()

accept(websocket)

Accept Event of a websocket event

check_subscriber_acl(doc, acl)

Check if subscriber has right to get the data

disconnect(websocket)

Disconnect the subscriber

document_sent_async(doc, op, seq)

Sending document in async mode

get_message_body(doc, data_scope, catalog, ...)

Get message body from document

send_json_async(websocket, content)

Send json message in async mode

send_message_async(websocket, message)

Send message to the target websocket

subscribe(websocket, class_name[, ...])

Subscribe to a connection

subscriber_is_connected(websocket)

Check if the websocket is connected

Attributes

active_connections

Connection library, organized by doc_class

async classmethod accept(websocket)

Accept Event of a websocket event

Parameters

websocket – websocket object

active_connections = {}

Connection library, organized by doc_class

classmethod check_subscriber_acl(doc: Document, acl)

Check if subscriber has right to get the data

Parameters
  • doc – document to control

  • acl – User access List

Returns

True if use has authorization else False

classmethod disconnect(websocket)

Disconnect the subscriber

Parameters

websocket

async classmethod document_sent_async(doc: Document, op: str, seq: str)

Sending document in async mode

Parameters
  • doc – Document object

  • op – Operation Type

  • seq – Create Sequence

classmethod get_message_body(doc: Document, data_scope: list, catalog: dict, show_hidden: bool) Optional[dict]

Get message body from document

Parameters
  • doc – Document object holding contents

  • data_scope – data scope

  • catalog – data catalog

  • show_hidden – Should show hidden value or not

Returns

json object if data on the scope else None

async classmethod send_json_async(websocket, content: dict)

Send json message in async mode

Parameters
  • websocket – websocket object

  • content (dict) – dictionary to be jsonify

async classmethod send_message_async(websocket, message: str)

Send message to the target websocket

Parameters
  • websocket – websocket object

  • message (str) – message content

async classmethod subscribe(websocket, class_name: str, data_scope: Optional[list] = None, catalog: Optional[dict] = None, show_hidden: bool = False, start_seq: str = '', acl=None, **kwargs)

Subscribe to a connection

Parameters
  • websocket – websocket object

  • class_name – Document Class Name

  • data_scope – The subset of data to be shown

  • catalog – data to be shown

  • show_hidden – Show hidden data or not

  • start_seq – Not interested on the message before this start sequence

  • acl – User access Control

Comments:
  • Know message to route to which client

  • Know the message content to be sent

classmethod subscriber_is_connected(websocket)

Check if the websocket is connected

Parameters

websocket – websocket object