tltneon / lgsl

LGSL v6.2.1/v7.0.0 for PHP 5.4-8.3+ (Live Game Server List): online status for CS2 (Source Query), Discord, FiveM, Rust, SA:MP, GMOD, Minecraft, Teamspeak and 200+ more games!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Create separate PHP library from the lgsl_protocol

Pasqualle opened this issue · comments

https://github.com/tltneon/lgsl/blob/master/lgsl_files/lgsl_protocol.php
This file needs a serious restructuring. It should even be a separate PHP library.
The rest of the codebase should be a PHP application.

For example I would expect a server query code something like this

use LGSL\Game\Quake3;
use LGSL\Client;

$client = new Client([
  'name' => 'LGSL/10.1',
  'timeout' => 10,
  'server' => [
    'game' => Quake3,
    'ip' => '127.0.0.1',
    'port' => '27960',
  ],
]);

/** @var \LGSL\Game\Quake3\Server $server */
$server = $client->connect();

///
print $server;

print $server->getMapName();
print $server->getGameTypeLabel();
print $server->getPlayerCount();
print_r($server->getPlayerNames());

This could improve the integration with CMSes and other PHP applications where the database and rendering system is already available.

Here is a similar php library for querying game servers
https://github.com/koraktor/steam-condenser/wiki/Usage-Examples-PHP

Im currently working on something like that, i will later post it, but dont expect something proffesional... It will be from newbie :D

commented

Saw it then you just started. Nice job, @ZekyTheWolf !
I'm not sure when I can make it by myself but something like that you can find in lgsl7 branch

Saw it then you just started. Nice job, @ZekyTheWolf ! I'm not sure when I can make it by myself but something like that you can find in lgsl7 branch

I made something that should work, its basicly rewrite of your lgsl_protocol.php

check it here, you can get it via composer or just download it... For now, it will be in beta and will not have stable release, testing purpose... Dont know what works and what not.

If you know servers for all supported games, i will happily test them later.

EDIT

@Pasqualle described what GameQ is doing, only difference is there that GameQ missing some queries that LGSL have, like discord.

Created discussion for it here #153 so this can be closed.