Skip to content

Instantly share code, notes, and snippets.

@imLinguin
Created October 26, 2023 13:11
Show Gist options
  • Save imLinguin/9b570476f7c6a80ab1bf9e14321b35fa to your computer and use it in GitHub Desktop.
Save imLinguin/9b570476f7c6a80ab1bf9e14321b35fa to your computer and use it in GitHub Desktop.

Heroic plugin system - TCP

Introduction

Heroic Games Launcher constantly expands it's feature set including new integrations and game stores support.

With more and more plans for new integrations the codebase becomes more and more bloated. This proposal showcases possible way of implementing plugin system based on TCP socket connection with well known and typed protocol.

Plugin definition

Matter of discussion: whether the plugins should be python only to provide consitent execution environment (similarily to GOG Galaxy)

Plugin is a CLI application accepting positional arguments in order

  • heroic version
  • TCP connection port

Plugin defines the manifest file which describes basic metadata like

  • name
  • version
  • issue report url
  • author
  • store id

Connection protocol

Bits are in low endian order.

Integers are in variable-sized format initially introduced in Sfio library. The encoding treats an integer as a number with base 128.

Most significant bit represents if the number continues on next byte. For example number 123456789 can be represented with four 7 bit digits with values: 58, 111, 26, 21. In order from most to least significant

+-------------------------------------------+
| 10111010 | 11101111 | 10011010 | 00010101 |
+-------------------------------------------+
   MSB+58     MSB+111    MSB+26     0+21

Socket messages are endcoded with protocolbuffers. Message payload is like follows

message type - integer
request id - integer
payload size - integer
...proto payload

Proto definitions will be distributed on separate repository, to be included as git submodule.

Handshake Flow

After being spawned the plugin is expected to connect to server protocol, and idenfify itself with special request which should include:

  • pid
  • plugin status

(to be expanded)

Heroic may drop the connection on error or if plugin with same store id is already initialized. Plugin should exit on such error

Auth Flow

Authorization is started always by Heroic. When plugin recieves auth request it should start the flow and return the URL that needs to be opened in webview for the user. Protobuf messagess will pass raw Headers, redirected URL and more that are required for plugin to properly authenticate the user.

Game library

Heroic will request list of internal app ids from each plugin and obtain common metadata from external endpoint like https://gamesdb.gog.com or custom equivelent.

Game installation and game page

Heroic shall not handle the detials of the games by itself. Plugins will respond with list of capabilities possible for specific game like LAUNCH, INSTALL, UNINSTALL, MOVE, VERIFY and more (to be expanded)

Error handling

If the plugin fails to initialize, fails to complete some request or encounters any other error it has to let the launcher know about that, in order to display appropriate error message to the user.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment