Back to menu';
}
}
else
{
// ok, we have the info to connect !
// generate the lua script
$cookie=convertCookieForActionHandler($_COOKIE["ryzomId"]);
global $FSHostLuaMode, $FSHostResult, $FSHostResultStr;
$FSHostResult = 1;
$FSHostResultStr = $shardAddr;
if ($FSHostLuaMode)
{
$luaScript='runAH(nil, "on_connect_to_shard", "cookie='.$cookie.'|fsAddr='.$shardAddr.'")';
//echo 'luaScript : '.$luaScript.'
';
echo '
Teleporting to shard
';
}
}
}
/**
* Receive the result of the shard list, then call the global $getShardListCallback with the associative array as argument
*/
function getShardsResult($userId, $resultStr)
{
global $getShardListCallback;
$onlineShardsBySessionId = array();
$resultArray = split(';', $resultStr);
foreach ($resultArray as $shardInfo)
{
$shardAttr = split(',', $shardInfo);
if (isset($shardAttr[1]))
$onlineShardsBySessionId[$shardAttr[0]] = $shardAttr[1];
}
$getShardListCallback($onlineShardsBySessionId);
}
}
// External use
$FSHostLuaMode = false;
$FSHostResultStr = 0;
// Internal use
$verbose = true;
$FSHostResult = 0;
// THE ABOVE DECLARATIONS ARE NEEDED FOR ALL CODE BELOW THIS LINE
if (isset($_POST["ml"]))
joinMainlandPost();
if (isset($_POST["destSessionId"]))
joinShardFromIdPost($_POST["destSessionId"]);
/**
* Authenticate and request to join a mainland shard
*/
function joinMainlandPost()
{
global $FSHostLuaMode;
$FSHostLuaMode = true;
$domainId = -1;
if (!validateCookie($userId, $domainId, $charId))
{
echo "Invalid cookie !";
die();
}
else
{
joinMainland($userId, $domainId);
}
}
/**
* Authenticate and request to join the specified shard
*/
function joinShardFromIdPost( $destSessionId )
{
$domainId = -1;
if (!validateCookie($userId, $domainId, $charId))
{
echo "Invalid cookie !";
die();
}
else
{
joinShardFromId($userId, $domainId, $destSessionId);
}
}
/**
* Request to join the specified shard
*/
function joinShardFromId( $userId, $domainId, $destSessionId )
{
$domainInfo = getDomainInfo($domainId);
$addr = split(":", $domainInfo["session_manager_address"]);
$RSMHost = $addr[0];
$RSMPort = $addr[1];
// request join to the session manager
$joinShard = new JoinShardCb;
$res = "";
$joinShard->connect($RSMHost, $RSMPort, $res);
$charSlot = getCharSlot(); // if ingame (!=15), the RSM can check if this character has the right to connect to the specified shard
$charId = ($userId<<4) + $charSlot;
echo "Requesting teleportation of $charId/$userId to shard session ".$destSessionId."...
";
$joinShard->joinSession($charId, $destSessionId, $domainInfo["domain_name"]);
// wait the the return message
if ($joinShard->waitCallback() == false)
{
// Note: the answer is a joinSessionResult message
echo "No response from server, joinShard failed
";
}
die();
}
/**
* Request to get the shard list
*/
function getShardList($userId, $domainId)
{
$domainInfo = getDomainInfo($domainId);
$addr = split(":", $domainInfo["session_manager_address"]);
$RSMHost = $addr[0];
$RSMPort = $addr[1];
// request get to the session manager
$joinShard = new JoinShardCb;
$res = "";
$joinShard->connect($RSMHost, $RSMPort, $res);
$charId = ($userId<<4)+15;
echo "Retrieving online shards for $charId...
";
$joinShard->getShards($charId);
// wait the the return message
if ($joinShard->waitCallback() == false)
{
echo "No response from server, getShards failed
";
}
die();
}
/**
* Display the list of mainland shards
* This is a candidate to the callback $getShardListCallback
*/
function displayAllShards(&$onlineShardsBySessionId)
{
// Get the userId and domainId back
$domainId = -1;
if (!validateCookie($userId, $domainId, $charId))
{
echo "Invalid cookie !";
die();
}
// List all shards of the domain, including offline ones
global $DBName, $DBHost, $DBUserName, $DBPassword;
$link = mysqli_connect($DBHost, $DBUserName, $DBPassword) or die("Can't connect to nel database");
mysqli_select_db($link, $DBName) or die ("Can't access to the db dbname:$DBName");
$domainId = (int) $domainId;
$query = "select * from shard where domain_id = $domainId";
$resShards = mysqli_query($link, $query) or die ("Can't execute the query: ".$query." ".mysqli_error($link));
echo "Select a shard to join:
";
//echo "