private function handleHeartbeat($attributes) { if (!isset($attributes['port']) || $attributes['port'] < 1 || $attributes['port'] > 65535) { $this->sendError("Wrong port for heartbeat"); $this->removeme = true; } elseif (!isset($attributes['gamename'])) { $this->sendError("Wrong message, needs gamename"); $this->removeme = true; } elseif ($attributes['gamename'] == "netpanzer") { if (isset($attributes['protocol']) && $attributes['protocol'] > 1 && $attributes['protocol'] < 65535) { $sinfo = ServerList::getServer($this->ip, $attributes['port']); if (!isset($sinfo)) { print "New server on {$this->ip}:{$attributes['port']}\n"; $sinfo = new ServerInfo($this->ip, $attributes['port'], $attributes['protocol'], $this); ServerList::addServer($sinfo); } else { print "Heartbeat of server on {$this->ip}:{$attributes['port']}\n"; $sinfo->clientSock = $this; $sinfo->protocol = $attributes['protocol']; } $sinfo->sendQuery(); } } elseif ($attributes['gamename'] == "master") { global $MASTERPASSWORD; if (isset($attributes['password']) && $attributes['password'] == $MASTERPASSWORD) { $sinfo = MasterList::getServer($this->ip, $attributes['port']); if (isset($sinfo)) { $sinfo->touch(); } else { print "New MasterServer connected: {$this->ip}:{$attributes['port']}\n"; $sinfo = new MasterInfo($this->ip, $attributes['port']); MasterList::addServer($sinfo); } } } }