examples.websockets package

Submodules

examples.websockets.listener_client module

This example shows how to use the MiddlewareCommunicator to send and receive messages over Websockets. It can be used to test the functionality of the Websockets using the PUB/SUB pattern. The example can be run on a single machine or on multiple machines. In this example (as with all other examples), the listener awaits a message over the topic ‘/hello/my_message’.

Requirements:
  • Wrapyfi: Middleware communication wrapper (refer to the Wrapyfi documentation for installation instructions)

  • Websockets (refer to the Wrapyfi documentation for installation instructions)

Run:

# PUB/SUB mode - Listener waits for message and prints the received object (assuming the websocket server is running). Only one instance of the websocket_server.py should be running

python3 listener_client.py

class examples.websockets.listener_client.HelloWorld[source]

Bases: MiddlewareCommunicator

receive_message()[source]

Exchange messages and mirror user input.

examples.websockets.publisher_client module

This example shows how to use the MiddlewareCommunicator to send and receive messages over Websockets. It can be used to test the functionality of the Websockets using the PUB/SUB pattern. The example can be run on a single machine or on multiple machines. In this example (as with all other examples), the publisher transmits a message over the topic ‘/hello/my_message’.

Requirements:
  • Wrapyfi: Middleware communication wrapper (refer to the Wrapyfi documentation for installation instructions)

  • Websockets (refer to the Wrapyfi documentation for installation instructions)

Run:

# PUB/SUB mode - Publisher transmits message and prints the received object (assuming the websocket server is running). Only one instance of the websocket_server.py should be running

python3 publisher_client.py

class examples.websockets.publisher_client.HelloWorld[source]

Bases: MiddlewareCommunicator

send_message(arg_from_requester='')[source]

Exchange messages and mirror user input.

examples.websockets.websocket_server module

Module contents