pubsub.proxy module¶
- class pubsub.proxy.PubSubWebSocketHandler(*args: Any, **kwargs: Any)¶
Bases:
WebsocketHandler
POX WebSocket server for interfacing with the pubsub service hoststack. Run with:
./pox.py web --no-cookieguard --port=[PORT] ext.ei.pubsub.scripts.pubsub --hssock=[SOCKNAME]
IPC messages are sent and received as JSON blobs. IPC JSON messages must always have a field “ipc” with a (string) value containing the message type. The remainder of the fields depend on the message type:
Client → Server IPCs:
- PubSub (un)publish/subscribe request (“PUBSUB_REQUEST”):
request_type: one of “PUBLISH”, “SUBSCRIBE”, “UNPUBLISH”, “UNSUBSCRIBE”
topic: topic to (un)publish/subscribe to
- Sending a message (“PUBSUB_OUTGOING_MESSAGE”):
seqno (optional): local sequence number of message
topic: topic to send message on
msg: message data
Example client publish request:
{ "ipc": "PUBSUB_REQUEST", "request_type": "PUBLISH", "topic": "example topic" }
Server → Client IPCs:
- Incoming message (“PUBSUB_INCOMING_MESSAGE”):
archive_seqno: sequence number of this message in the pubsub core
topic: topic that this message was published to
msg: message data
- Request ACK (“PUBSUB_REQUEST_ACK”):
request_type: request type being ack’d
archive_seqno: sequence number of this request in the pubsub core
topic: topic that was (un)published/subscribed
- Outgoing message ACK (“PUBSUB_MSG_ACK”):
seqno: matches the seqno field of the outgoing message if given, otherwise zero
archive_seqno: sequence number of this message in the pubsub core
Example incoming message from server:
{ "ipc": "PUBSUB_INCOMING_MESSAGE", "archive_seqno": 17, "topic": "example topic", "msg": "This is a PubSub message." }
- pubsub.proxy.launch(hssock)¶