server.events package

This package implements socket.io event handlers.
  • namespace “/device” communicates with devices (listen for emitted data, forward commands from frontend)

  • namespace “/client” communicates with frontend (listen for command requests and send state updates)

Submodules

server.events.client module

server.events.client.on_check_devices(_)[source]

Client (admin) triggers status check on all devices.

server.events.client.on_command(command)[source]

Forward command to device.

server.events.client.on_connect()[source]
server.events.client.on_disconnect()[source]
server.events.client.on_stats(client_stats)[source]

Client sends its most recent stats and requests update on server stats.

server.events.device module

server.events.device.device_registered(f)[source]
server.events.device.on_command_state(device_id, data)[source]

Forward new default state of parameters of a command to client.

server.events.device.on_connect(device)[source]

Accept authenticated connection and add device to sid database.

server.events.device.on_disconnect()[source]

Delete device from sid database.

server.events.device.on_entity(device_id, name_data)[source]

Handle new/updated entity emitted by a device.

server.events.device.on_file(device_id, data)[source]

Save data temporarily on server and forward file metadata to client. No ResourceManager is used - each datafile is represented purely by its id saved in ‘devices’, where id == filename.

server.events.device.on_register(data)[source]

Register new device - show it to clients.

server.events.device.on_unregister(device_id)[source]

Unregister device - delete all resources and hide it from clients.

server.events.update_frontend module

server.events.update_frontend.emit_full_update(client_sid=None)[source]

Send full update to frontend. Includes all entities.

Parameters:

client_sid – specify which client should recieve the update, or use client_sid=None to emit to all clients

server.events.update_frontend.emit_update(**updated_entities)[source]

Send small update to frontend. Contains up to one entity of each type.

Typical usage:
  • send a single child-entity when updating existing data

  • send a child-entity together with parent-entity (device) when sending a brand new child-entity

Example:

update_partial(device=data_device, value={“value”: 3.2})