| 1: | <?php | 
| 2: |  | 
| 3: |  | 
| 4: |  | 
| 5: |  | 
| 6: |  | 
| 7: |  | 
| 8: |  | 
| 9: |  | 
| 10: |  | 
| 11: |  | 
| 12: |  | 
| 13: |  | 
| 14: |  | 
| 15: |  | 
| 16: |  | 
| 17: |  | 
| 18: |  | 
| 19: |  | 
| 20: | namespace GameQ\Protocols; | 
| 21: |  | 
| 22: | use GameQ\Exception\Protocol as Exception; | 
| 23: | use GameQ\Result; | 
| 24: |  | 
| 25: |  | 
| 26: |  | 
| 27: |  | 
| 28: |  | 
| 29: |  | 
| 30: |  | 
| 31: |  | 
| 32: |  | 
| 33: | class Arksa extends Eos | 
| 34: | { | 
| 35: |  | 
| 36: |  | 
| 37: |  | 
| 38: |  | 
| 39: |  | 
| 40: | protected $protocol = 'arksa'; | 
| 41: |  | 
| 42: |  | 
| 43: |  | 
| 44: |  | 
| 45: |  | 
| 46: |  | 
| 47: | protected $name_long = 'ARK: Survival Ascended'; | 
| 48: |  | 
| 49: |  | 
| 50: |  | 
| 51: |  | 
| 52: |  | 
| 53: |  | 
| 54: | protected $name = 'arksa'; | 
| 55: |  | 
| 56: |  | 
| 57: |  | 
| 58: |  | 
| 59: |  | 
| 60: |  | 
| 61: | protected $grant_type = 'client_credentials'; | 
| 62: |  | 
| 63: |  | 
| 64: |  | 
| 65: |  | 
| 66: |  | 
| 67: |  | 
| 68: | protected $deployment_id = 'ad9a8feffb3b4b2ca315546f038c3ae2'; | 
| 69: |  | 
| 70: |  | 
| 71: |  | 
| 72: |  | 
| 73: |  | 
| 74: |  | 
| 75: | protected $user_id = 'xyza7891muomRmynIIHaJB9COBKkwj6n'; | 
| 76: |  | 
| 77: |  | 
| 78: |  | 
| 79: |  | 
| 80: |  | 
| 81: |  | 
| 82: | protected $user_secret = 'PP5UGxysEieNfSrEicaD1N2Bb3TdXuD7xHYcsdUHZ7s'; | 
| 83: |  | 
| 84: |  | 
| 85: |  | 
| 86: |  | 
| 87: |  | 
| 88: |  | 
| 89: |  | 
| 90: | public function processResponse() | 
| 91: | { | 
| 92: | $serverData = parent::processResponse(); | 
| 93: |  | 
| 94: |  | 
| 95: | $filtered = array_filter($serverData, function ($session) { | 
| 96: | return $session['attributes']['ADDRESSBOUND_s'] === "{$this->serverIp}:{$this->serverPortQuery}" || | 
| 97: | $session['attributes']['ADDRESSBOUND_s'] === "0.0.0.0:{$this->serverPortQuery}"; | 
| 98: | }); | 
| 99: |  | 
| 100: | if (!$filtered) { | 
| 101: | throw new Exception('No matching sessions found for the specified port.'); | 
| 102: | } | 
| 103: |  | 
| 104: | $session = reset($filtered); | 
| 105: |  | 
| 106: | $result = new Result(); | 
| 107: |  | 
| 108: |  | 
| 109: | $result->add('hostname', $this->getAttribute($session['attributes'], 'CUSTOMSERVERNAME_s', 'Unknown')); | 
| 110: | $result->add('mapname', $this->getAttribute($session['attributes'], 'MAPNAME_s', 'Unknown')); | 
| 111: | $result->add('password', $this->getAttribute($session['attributes'], 'SERVERPASSWORD_b', false)); | 
| 112: | $result->add('numplayers', $this->getAttribute($session, 'totalPlayers', 0)); | 
| 113: | $result->add('maxplayers', $this->getAttribute($session['settings'], 'maxPublicPlayers', 0)); | 
| 114: | $result->add('anticheat', $this->getAttribute($session['attributes'], 'SERVERUSESBATTLEYE_b', false)); | 
| 115: | $result->add('allowJoinInProgress', $this->getAttribute($session['settings'], 'allowJoinInProgress', false)); | 
| 116: | $result->add('day', $this->getAttribute($session['attributes'], 'DAYTIME_s', '')); | 
| 117: | $result->add( | 
| 118: | 'version', | 
| 119: | "v" . $this->getAttribute($session['attributes'], 'BUILDID_s', '0') . "." . | 
| 120: | $this->getAttribute($session['attributes'], 'MINORBUILDID_s', '0') | 
| 121: | ); | 
| 122: | $result->add('pve', (bool) $this->getAttribute($session['attributes'], 'SESSIONISPVE_l', false)); | 
| 123: | $result->add('officialserver', (bool) $this->getAttribute($session['attributes'], 'OFFICIALSERVER_s', false)); | 
| 124: |  | 
| 125: |  | 
| 126: | return $result->fetch(); | 
| 127: | } | 
| 128: | } | 
| 129: |  |