tree: 641af6a5a2db7a3cccf7f3f330ec110a9c7f5f71 [path history] [tgz]
  1. assets/
  2. certs/
  3. constants/
  4. Android.bp
  5. client_handler.cpp
  6. client_handler.h
  7. device_handler.cpp
  8. device_handler.h
  9. device_list_handler.cpp
  10. device_list_handler.h
  11. device_registry.cpp
  12. device_registry.h
  13. Readme.md
  14. server.cpp
  15. server_config.cpp
  16. server_config.h
  17. signal_handler.cpp
  18. signal_handler.h
  19. utils.cpp
  20. utils.h
host/frontend/webrtc_operator/Readme.md

This signaling server defines a very simple protocol to allow the establishing of a WebRTC connection between clients and devices. It should only be used for development purposes or for very simple applications with no security, privacy or scalability requirements.

Serious applications should build their own signaling server, implementing the protocol exactly as defined below (any modifications would likely require modifications to the client and/or device which will then not be maintained by the cuttlefish team).

The signaling server MUST expose two (different) websocket endpoints:

  • wss:///register_device
  • wss:///connect_client

Additional endpoints are allowed and are up to the specific applications. Extending the messages below with additional fields should be done with extreme care, prefixing the field names with an applciation specific word is strongly recommended. The same holds true for creating new message types.

Devices connect to the register_device endpoint and send these types of messages:

  • {“message_type”: “register”, “device_id”: , “device_info”: }

  • {“message_type”: “forward”, “client_id”: , “payload”: }

The server sends the device these types of messages:

  • {“message_type”: “config”, “ice_servers”: , ...}

  • {“message_type”: “client_msg”, “client_id”: , “payload”: }

  • {“message_type”: “client_disconnected”, “client_id”: }

  • {“error”: }

Clients connect to the connect_client endpoint and send these types of messages:

  • {“message_type”: “connect”, “device_id”: }

  • {“message_type”: “forward”, “payload”: }

The server sends the clients these types of messages:

  • {“message_type”: “config”, “ice_servers”: , ...}

  • {“message_type”: “device_info”, “device_info”: }

  • {“message_type”: “device_msg”, “payload”: }

  • {“error”: }

A typical application flow looks like this:

  • Device connects to register_device

  • Device sends register message

  • Server sends config message to Device

  • Client connects to connect_client

  • Client sends connect message

  • Server sends config message to Client

  • Server sends device_info message to Client

  • Client sends forward message

  • Server sends client_msg message to Device (at this point the device knows about the client and cand send forward messages intended for it)

  • Device sends forward message

  • Server sends device_msg message to client

  • ...

In an alternative flow, not supported by this implementation but allowed by the design, the Client connects first and only receives a config message from the Server, only after the Device has sent the register message the Server sends the device_info messaage to the Client.