gym_anm.envs.anm6_env.rendering.py.servers.WsServer

class gym_anm.envs.anm6_env.rendering.py.servers.WsServer[source]

Bases: object

Encapsulates a WebSocket server.

PORT

The port on which to listen. Default is 9001.

Type:

int

HOST

The host used as server. Default is ‘127.0.0.1’.

Type:

str

address

The full hosting address to connect to the server.

Type:

str

clients

The clients currently connected to the server.

Type:

dict of {int : dict}

init_message

The initial message received, then sent to every new client.

Type:

str

init_client

The client which sent the initial message.

Type:

dict

process

The separate process running the server.

Type:

multiprocessing.Process

__init__()[source]

Methods

__init__()

client_left(client, server)

Action taken when a client closes the connection with the server.

msg_received(client, server, msg)

Action taken when a message is received.

new_client(client, server)

Action taken when a new client connects to the server.

client_left(client, server)[source]

Action taken when a client closes the connection with the server.

Parameters:
  • client (dict) – The client which just closed the WebSocket connection.

  • server (websocket_server.websocket_server.WebsocketServer) – The current server.

msg_received(client, server, msg)[source]

Action taken when a message is received.

Parameters:
  • client (dict) – The client that sent the message.

  • server (websocket_server.websocket_server.WebsocketServer) – The current server.

  • msg (str) – The message received in JSON format.

new_client(client, server)[source]

Action taken when a new client connects to the server.

Parameters:
  • client (dict) – The new client.

  • server (websocket_server.websocket_server.WebsocketServer) – The current server.