This is a simple API that receives data from PUBGM Observer (PCOB) and sends it to the PUBGM HUD.
- Clone the repository
- Install the dependencies
pip install -e .-
Create a
configfolder insrcfolder according to the example inexamples/config. -
Run the API
python src/main.pyIf you want to run the packaged version, you can run package.py and then use the executable in dist folder. Make sure to have the config folder in the same directory as the executable.
As you can see in the example config.json file, you can configure the API to send data to the PUBGM HUD.
PCOB sends data at /totalmessage endpoint and from there you can use the sync and custom sections to send the data to the PUBGM HUD. You can check the data that we use from the request body in the PCOB Data file.
Specifications:
- tag: The custom tag of the endpoint which can be used to get the appropriate config (
SyncConfig) from theconfig.jsonfile. - endpoint: The endpoint of the PUBGM HUD API.
- request_body: The request body of the endpoint. You can pass hardcoded values or use the
{{ variable_name }}syntax just like Jinja2 to pass the data from the PCOB request.
To get the sync config you can use the function called get_sync_configs which is located in src/config.py and it requires a tag parameter which is the custom tag of the endpoint. This function returns a list of SyncConfig objects even if there is only one config with the same tag. To get the custom config you can use the get_custom_configs function instead.
You will need to use the function called replace_request_body_keys to replace the {{ variable_name }} with the actual value. This function is located in src/utils/request.py and it requires a SyncConfig object and a dict object with the key of the same variable name as the {{ variable_name }} in the request_body and the value can be anything from the PCOB request.
Custom functions are located in src/customs/customs.py and they are called when the PCOB request is received at /totalmessage endpoint and they are being run with the run_customs function.
In this version, custom functions are triggered only after the match has finished, and specifically 3 seconds after the last /totalmessage request for that match. This delay is intentional: when a match ends, PCOB sends several requests in quick succession, but some may contain incomplete or inaccurate data. By waiting for 3 seconds after the final request, we ensure that only the most complete and accurate data is used for custom endpoints.
When the match is finished and the custom functions have completed running, the API does not send any more requests to the PUBGM HUD. The total player list and team info list are no longer sent, nor are the custom functions executed again, unless another request is received with a different FinishedStartTime or the API server is restarted.
This project is licensed under the MIT License - see the LICENSE file for details.