[WIP] Client/Server process separation #1125
Open
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 will add a PicoTorrent Server process which will be used for all BitTorrent related things, keeping the UI clean from libtorrent and adding a WebSocket and HTTP JSONRPC API to the server process. Ideally with no breaking changes.
The server process will have a HTTP listener where you can connect to either
/api/ws
to receive WebSocket events, or/api/jsonrpc
to post JSONRPC requests. It will also add support for serving static files under/
which can be used for serving a SPA for remote management.The basic idea here is to have a server process which can be run either as part of the client, or stand-alone and connect either a regular PicoTorrent desktop client to it or managed by the web UI. The desktop application will receive events on the WebSocket to keep UI in sync, and issue JSONRPC requests to modify state.
JSONRPC methods to implement:
core.getVersion
- gets version information for all libraries.config.get
- gets the application config, i.e can be anything the application chooses to store.config.set
- sets a config value, anything the application wants.session.findMetadata
- begins a DHT metadata search for a torrent based on a info hash.session.getSettings
- get the libtorrent session settings.session.setSettings
- sets the libtorrent session settings.session.pause
- pauses the session.session.resume
- resumes the session.session.setIPFilter
- sets the IP filter configuration.session.getIPFilter
- gets the IP filter configuration.session.addTorrent
- adds a torrent.torrents.toJSON
- takes a base64 encoded torrent file and returns it in JSON format. To be used when previewing a torrent in the UI.torrents.remove
- remove one or more torrents based on info hash, optionally removing the files as well.torrents.pause
- pause one or more torrents based on info hash.torrents.resume
- resume one or more torrents based on info hash, optionally passing theforce
flag.torrents.move
- moves one or more torrents based on info hash, optionally passing a flag to overwrite files in the destination.torrents.prioritizeFiles
- prioritizes the files in a torrent.torrents.renameFiles
- renames one or more files in a torrent.torrents.prioritizePieces
- prioritizes the pieces in a torrent.torrents.addTracker
- adds one or more trackers to a torrenttorrents.removeTracker
- removes one or more trackers from a torrent.WebSocket events to implement:
init
- sent when a client connects to the WebSocket. Contains all the initial state needed to keep the UI in sync.torrents.added
- a torrent was added.torrents.removed
- a torrent was removed.torrents.moved
- a torrent was moved.torrents.updated
- one or more torrents had their states updated.torrents.error
- one or more torrents transitioned into the error state.torrents.paused
- a torrent was paused.torrents.resumed
- a torrent was resumed.Events and JSONRPC methods are subject to change.