The main concept to understand is the Process Global Map of Websockets:
The Key is any unique identifier that you choose to identify a physical device, such as its mac address. or username, or Postcode.
The Value is the actual websocket object. This allows you to find the appropriate websocket object to get to the physical device.
To populate the map, the Client calls a Sub on the server (with its unique identify as a parameter) when the Websocket Connection succeeds. The server sub Puts this entry into the Global Map.