Download Center
Metin2 Rest API
Metin2 Rest API - Laravel Service
Server Side API
Secure your ports, the zip has basic middleware but you need to wire it up yourself as I'm using libenvpp for configuration instead of the default setup, I also use SPDLOG if you want you can wire your own logger in the API.cpp file.
Why?
Have you ever wanted to ditch the old API because you don't like TCP? Me too! Now you can do it with this
Requirements
CrowCpp/Crow
Installing requirements (Using vcpkg and CMake)
Run command.
vcpkg install crow
Example Output
{
"channels": {
"13000": "NORM",
"13001": "NORM",
"13002": "NORM",
"13003": "NORM",
"13004": "NORM",
"13005": "NORM",
"13099": "NORM"
},
"shop_count": 0,
"user_count": 0
}
Changes
Download the zip and paste it on your db/src
db/src/Main.cpp
[Hidden Content]
db/src/ClientManager.h
[Hidden Content]
To get proper status on startup you need to start your game cores AFTER the db NEVER BEFORE OR AT THE SAME TIME
Below there's an example for people using the Metin2 on LINUX project
In your docker-compose.yml or compose.yml
Add ports (18080) to your db service as well as the healthcheck, example below:
db:
image: ${GAME_IMAGE}
restart: always
env_file:
- .env
expose:
- ${DB_PORT}
ports:
- "18080:18080"
command: db
volumes:
- ./storage/log/db/:/app/log/
depends_on:
database:
condition: service_healthy
healthcheck:
test: "curl --silent --fail [Hidden Content] > /dev/null || exit 1"
interval: 10s
timeout: 5s
retries: 5
networks:
- metin2
And all your cores should have db with service_healthy for your dependencies, example below
ch1_first:
image: ${GAME_IMAGE}
restart: always
environment:
GAME_HOSTNAME: ch1_first
GAME_CHANNEL: 1
GAME_MARK_SERVER: true
GAME_PORT: 13000
GAME_P2P_PORT: 14000
GAME_MAP_ALLOW: 1 3 4 5 6 21 23 24 25 26 41 43 44 45 46 91 92 93 107 112 201
env_file:
- .env
expose:
- 13000
- 14000
ports:
- "13000:13000"
command: game
volumes:
- ./storage/log/ch1/first/:/app/log/
- ./storage/mark/:/app/mark/
depends_on:
db:
condition: service_healthy
networks:
- metin2
Middleware Configuration
THIS WILL ONLY PLUG AND PLAY IF YOU'RE USING libenvpp
db/src/Config.cpp
[Hidden Content]
db/src/Main.cpp
[Hidden Content]
In your .env add
[Hidden Content]
Usage
There's also a Laravel 12 compatible service in the downloads with the example usage below
public function __invoke(Request $request)
{
$status = (new ServerApiService)->fetchStatus();
if (! $status) {
return 'No data';
}
return [
'channels' => $status->getChannels(),
'userCount' => $status->getUserCount(),
'shopCount' => $status->getShopCount(),
'ch1' => $status->getChannel(13000)->value,
];
}
Credits
@ Gurgarath I basically stole his idea