Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cactoes/leaguepp-connector
A league of legends client connector written in c++20
https://github.com/cactoes/leaguepp-connector
cmake cpp cpp20 league-of-legends league-of-legends-api library websocket
Last synced: about 2 months ago
JSON representation
A league of legends client connector written in c++20
- Host: GitHub
- URL: https://github.com/cactoes/leaguepp-connector
- Owner: cactoes
- License: mit
- Created: 2024-02-27T21:49:06.000Z (10 months ago)
- Default Branch: master
- Last Pushed: 2024-03-04T14:40:40.000Z (10 months ago)
- Last Synced: 2024-03-05T01:49:40.213Z (10 months ago)
- Topics: cmake, cpp, cpp20, league-of-legends, league-of-legends-api, library, websocket
- Language: C++
- Homepage:
- Size: 33.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## league++connector
a league of legends client connector written in c++20.this library makes use of [nlohmann/json](https://github.com/nlohmann/json) for the json side of things.
> [!NOTE]
> windows only since league is windows only.## examples
here is an full [example](example/src/main.cpp) of the library.### connecting to the client
the header file exposes a function to connect to the client which takes in a config.
```cpp
#include
//...// setup the config
connector::config_t config = {};
// enabling this will enable debugging for WebSocket++
config.enableWebSocketLogging = false;
// set function pointers to handlers for connect & disconnect events
config.connectHandler = &ConnectHandler;
config.disconnectHandler = &DisconnectHandler;
// after how many ms should the connector try again to connect
config.reconnectInterval = 1000;// connect to the client using our config
connector::Connect(config);
```### adding event handlers
to listen to events you'll need to pass the endpoint uri & an handler.
```cpp
#include
// ...// this is what a handler looks like. always void(string, json)
void OnClientEvent(std::string uri, nlohmann::json data) { /* ... */ }connector::AddEventHandler("/event/you-want-to-listen/to", &OnClientEvent)
```
while this list is outdated a lot of events are listed [here](https://lcu.vivide.re/) (for Client Version: 8.24)### making requests to the client
```cpp
#include
// ...auto result = connector::MakeRequest(connector::request_type::POST, "/uri", "\"EXTRA_JSON_DATA_HERE (if needed)\"");
// result.data will hold a json object of the data
// result.status will hold the http status code of the request
if (result.status != 200) {
std::cout << "request failed\n";
}
```## including
make sure to use the `--recursive` flag when cloning this repository
```cmake
# ================
# library: OpenSSL (v3)
# note: required for cpp-httplib
# ================
set(OPENSSL_USE_STATIC_LIBS TRUE)
find_package(OpenSSL REQUIRED)
target_link_libraries(${PROJECT_NAME} PRIVATE OpenSSL::SSL)# ================
# library: Boost
# note: required for WebSocket++
# ================
set(Boost_USE_STATIC_LIBS TRUE)
add_definitions("-D_WEBSOCKETPP_CPP11_STL_")
find_package(Boost REQUIRED COMPONENTS system)
target_include_directories(${PROJECT_NAME} PRIVATE Boost::headers)
target_link_libraries(${PROJECT_NAME} PRIVATE Boost::system)# ================
# library: league++connector
# ================
add_subdirectory(PATH_TO_THIS_LIBRARY)
target_link_libraries(${PROJECT_NAME} PRIVATE leaguepp_connector)
```## prerequisites
these are required development packages that need to be properly installed on your system.
* `openssl` (v3) (https://www.openssl.org/)
* `boost` (> v1.84.0) (https://www.boost.org/)## notes
this was tested & built using:
* Microsoft Visual C++ 2022 / Build Tools x64
* Windows 10## License
[MIT](LICENSE)