refactor(proxy): simplify `runSession()` and `Start()`
This slightly modifies the behavior of the proxy: now it will not wait for the client connection to succeed / fail before polling the broker another time. This might make the verbose logs a little more messy. But the poll interval is still respected.
This removes tokens.ret() from runSession()
and from datachannelHandler,
and moves the call to connectToRelay() to runSession().
Now the flow of runSession() is more straight-forward, with no indirect callbacks:
- Create a WebRTC connection.
- Send answer.
- Connect to client.
- Connect to server.
- Pipe the data.
I ran the proxy with this patch for a couple of minutes, with capacity=2. It appears to work fine.
This refactor will also allow us to add country stats to failed connection metrics !516 (comment 3163596)
Edited by WofWca