This commit updates the agent to use a websocket to maintain a persistent connection to the Reflect API over which Reflect can communicate when new sessions are created or completed. This removes the need to poll the Reflect API over HTTP to identify when the account's active sessions have changed. Additionally, it lowers the latency between session launch and the establishment of the wireguard connection to the host instance.
The agent sends an initial request for "sessions", but after that, it simply listens for the updated sessions information from the server. If the server disconnects or fails, the agent will retry the connection.
Tested
Ran with the updated Reflect API and verified it connects
Verified if the server dies and restarts the agent reconnects
Verified that new sessions trigger an update in the agent's wireguard config
Fixes #10
This commit updates the agent to use a websocket to maintain a persistent connection to the Reflect API over which Reflect can communicate when new sessions are created or completed. This removes the need to poll the Reflect API over HTTP to identify when the account's active sessions have changed. Additionally, it lowers the latency between session launch and the establishment of the wireguard connection to the host instance.
The agent sends an initial request for "sessions", but after that, it simply listens for the updated sessions information from the server. If the server disconnects or fails, the agent will retry the connection.
Tested