I'm trying to send a prefix message towards a relay through tunnelSendDataFromString.
This does work if i change the login towards the own serverlogin. But if i try to send it towards the Relay server it seems its being dissolved in mid-air.
It does appear in the callback of Maniaplanet.TunnelDataRecieved but then it doesn't do anything.
I and maybe other server owners / coders do not want to run two server accounts do to they fact that it might be troubled to do so.
Hope this can be fixed in an overall issue.
Below is the code i tried to work on:
Code: Select all
<?php
/**
* RelayChat
* @name RelayChat
* @data-made 08-02-2013
* @date-finished 08-02-2013
* @version 1.0
* @package RelayChat
*
* @author Willem van den Munckhof
* @copyright © 2013
*
* ---------------------------------------------------------------------
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* ---------------------------------------------------------------------
* You are allowed to change things or use this in other projects, as
* long as you leave the information at the top (name, date, version,
* website, package, author, copyright) and publish the code under
* the GNU General Public License version 3.
* ---------------------------------------------------------------------
*/
namespace ManiaLivePlugins\Test\Test;
use ManiaLive\Utilities\Console;
use DedicatedApi\Xmlrpc\Base64;
class Test extends \ManiaLive\PluginHandler\Plugin {
public $isrelay = false;
public $relaymaster = null;
public $relaylist = array();
/**
* onInit()
* Function called on initialisation of ManiaLive.
*
* @return void
*/
function onInit() {
$this->setVersion('0.0.1');
}
/**
* onLoad()
* Function called on loading of ManiaLive.
*
* @return void
*/
function onLoad() {
$this->enableDedicatedEvents();
}
public function onReady() {
$this->onShow();
}
function onShow() {
Console::println(' #####################################################################');
Console::println('[eXpension Pack] Checking for a ManiaChannel!');
try {
$playerspeclist = $this->connection->getPlayerList(300,1,3);
$this->relaylist = $playerspeclist;
foreach ($playerspeclist as $plspeclist)
{
//var_dump($plspeclist->spectatorStatus);
//var_dump($plspeclist->login);
if ($plspeclist->isServer == true && $plspeclist->spectatorStatus == 2551101){
Console::println('[eXpension Pack] Found a ManiaChannel: Login: '.$plspeclist->login.'');
Console::println('[eXpension Pack] Found a ManiaChannel: Nickname: '.$plspeclist->nickName.'');
Console::println(' #####################################################################');
}
elseif ($plspeclist->isServer == false && $plspeclist->spectatorStatus == 0){
}
}
} catch (\Exception $e) {
Console::println('[eXpension Pack] No ManiaChannel Found!');
}
$this->SendtoRelay();
}
function SendtoRelay(){
$data = 'Hello! Welcome to the TM2 Stadium RelayChat plugin made by w1lla';
$data64len = strlen($data);
if($data64len > 5450){ // using TunnelSendDataToId
Console::println('sendToRelay:: Error, data too big: encoded/compressed data exceed 5450 bytes ('.$data64len.') !');
return false;
}
//var_dump($data);
$sent = $this->connection->tunnelSendDataFromString($this->relaylist[0]->login, $data);
//var_dump($sent);
var_dump($this->relaylist[0]->login);
}
function onTunnelDataReceived($playerUid, $login, $data) {
var_dump($login);
var_dump($playerUid);
$this->connection->chatSendServerMessage($data, $login);
}
}
?>