PublishServer#

class wattson.cosimulation.control.interface.publish_server.PublishServer(simulation_control_server: WattsonServer, socket_string: str, namespace: Namespace | None = None, **kwargs)#

Bases: Thread

Handles broadcast messages issued by the WattsonServer

Methods

__init__

param simulation_control_server:

The associated WattsonServer instance

broadcast

Sends the given notification to all connected clients.

get_history

is_ready

multicast

Sends the given notification to all connected clients, but sets the message's recipient list to contain the given peer IDs such that other peers ignore this message.

notify

Sends the given notification as it is.

run

Method representing the thread's activity.

start

Start the thread's activity.

stop

unicast

Sends the given notification to all connected clients, but sets the message's recipient list to the single given peer ID such that other peers ignore this message.

wait_until_ready

__init__(simulation_control_server: WattsonServer, socket_string: str, namespace: Namespace | None = None, **kwargs)#
Parameters:
  • simulation_control_server ('WattsonServer') – The associated WattsonServer instance

  • socket_string (str) – The socket’s connection string, e.g. tcp://IP:PORT

  • namespace (Optional[Namespace], optional) – (Default value = None)

  • **kwargs

broadcast(simulation_notification: WattsonNotification)#

Sends the given notification to all connected clients.

Parameters:

simulation_notification (WattsonNotification) – The notification to send.

multicast(simulation_notification: WattsonNotification, recipients: List[str])#

Sends the given notification to all connected clients, but sets the message’s recipient list to contain the given peer IDs such that other peers ignore this message.

Parameters:
  • simulation_notification (WattsonNotification) – The notification to send.

  • recipients (List[str]) – A list of peer IDs to send the notification to

notify(simulation_notification: WattsonNotification)#

Sends the given notification as it is. Only if no recipients are given, the notification is actively broadcasted.

Parameters:

simulation_notification (WattsonNotification) – The notification to send.

run() None#

Method representing the thread’s activity.

You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.

start() None#

Start the thread’s activity.

It must be called at most once per thread object. It arranges for the object’s run() method to be invoked in a separate thread of control.

This method will raise a RuntimeError if called more than once on the same thread object.

unicast(simulation_notification: WattsonNotification, recipient: str)#

Sends the given notification to all connected clients, but sets the message’s recipient list to the single given peer ID such that other peers ignore this message.

Parameters:
  • simulation_notification (WattsonNotification) – The notification to send.

  • recipient (str) – The peer ID of the client to send the notification to