keeperfx
keeperfx copied to clipboard
API: TCP server for Inter-process Communication (IPC) - Interact with the game from a different application
This PR implements a TCP server that makes it so other applications can interact with KeeperFX. This can be used for stuff like Twitch interactions, but could prove useful for many things. It is still a draft but the current code should already 'kind of' work.
The current code allows executing a MAP SCRIPT COMMAND from another application.
Video: https://youtu.be/8ipvNPkRXjw ( The video is still showcasing a named pipe that I tried before switching to a TCP server)
The current TCP server can be connected to with telnet
telnet 127.0.0.1 5599
TODO:
- Fix errors/warnings
- Cleanup at end of map + make sure it works after switching and loading maps
- Make it so the client can connect/disconnect but also keep an open handle (Allow client to keep sending messages)
- Add hardcoded messages to return values / map data / campaign data
- CFG variable to turn on/off
- Allow commands that normally require conditions (ex: LOSE_GAME)
Maybe:
- Look into multiple clients?
- Consider JSON?
- Console commands as well?
After:
- Documentation for 3rd party developers
- A open-source sample tool so people can check it out -> little GUI that shows map info and allows to send commands
Notes:
- It might be required (since Windows 10) that the application interacting with the pipe needs to be a parent or child of the process. I am unable to test this at the moment.
- The 5599 port will most likely be configurable so you can theoretically have 2 keeperfx instances running with different TCP servers