Introduce a web socket server for faster communications and ability to re-authenticate. #376
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This introduces a web socket server so to allow sending player events more efficiently. It also supports a "reauth" event to allow the player to reauthenticate again (if username/password is provided in the command line interface).
The purpose of this is to make it easier to build smart player interfaces around librespot. In particular, "reauth" is useful in dealing with the occasional connection dropping issue making the player not appearing in the sportily web API player list unless the user actively connect to it through an official spotify app in the same network again.
To use this, add
--ws-port <port_number>
to the command, this will start a web socket server listening at<port_number>
. Then, with any web socket client can connect to this port. Once connected, the client will receive messages when the player state is updated like so:The client can also send the following message to the server:
If
--ws-port <port_number>
is not provided it will not spawn any web socket server.