Skip to content

Communication

gradysim.protocol.messages.communication

This file contains definitions for the communication commands. These commands are sent to the communication module to instruct it to perform some communication action, generally sending a message to another node.

CommunicationCommand dataclass

Represents a communication command. Communication commands are sent to the communication module to instruct it to perform some communication action, generally sending a message to another node.

Source code in gradysim/protocol/messages/communication.py
@dataclass
class CommunicationCommand:
    """
    Represents a communication command. Communication commands are sent to the communication module to instruct it to
    perform some communication action, generally sending a message to another node.
    """
    command_type: CommunicationCommandType
    """The type of the communication command"""

    message: str
    """The message to send"""

    destination: Optional[int] = None
    """The destination node ID. It's not necessary for a broadcast message"""

command_type: CommunicationCommandType instance-attribute

The type of the communication command

destination: Optional[int] = None class-attribute instance-attribute

The destination node ID. It's not necessary for a broadcast message

message: str instance-attribute

The message to send

CommunicationCommandType

Bases: int, Enum

Enum that defines the types of communication commands

Source code in gradysim/protocol/messages/communication.py
class CommunicationCommandType(int, Enum):
    """
    Enum that defines the types of communication commands
    """
    SEND = 0
    """Send a message to a specific node"""
    BROADCAST = 1
    """Send a message to all nodes"""

BROADCAST = 1 class-attribute instance-attribute

Send a message to all nodes

SEND = 0 class-attribute instance-attribute

Send a message to a specific node