2 require_once('../tools/validate_cookie.php');
3 include_once('../login/config.php');
4 include_once('../tools/domain_info.php');
5 include_once('ring_session_manager_itf.php');
7 class InvitePioneerCb
extends CRingSessionManagerWeb
9 function invokeResult($userId, $resultCode, $resultString)
11 global $step, $rsmProxy, $rsmSkel, $userId, $callbackClient;
13 echo "Receive result";
17 echo "<h1>The character ".$_POST["charName"]." have been invited in session ".$_POST["sessionId"].".</h1>";
21 echo "<h1>Failed to invite player ".$_POST["charName"]." in session ".$_POST["sessionId"]." : ".$resultString."</h1>";
29 if (!validateCookie($userId, $domainId, $charId))
31 echo "Invalid cookie !";
35 echo "Welcome user $userId<BR>";
37 $domainInfo = getDomainInfo($domainId);
38 $addr = split(":", $domainInfo["session_manager_address"]);
42 if (isset($_POST["execute"]))
44 // lookup in the database to convert character name into
45 global $DBHost, $RingDBUserName, $RingDBPassword;
47 $link = mysqli_connect($DBHost, $RingDBUserName, $RingDBPassword) or die ("Can't connect to database host:$DBHost user:$RingDBUserName");
48 mysqli_select_db($link, $domainInfo['ring_db_name']) or die ("Can't access to the table dbname:" . $domainInfo['ring_db_name']);
50 // extract the character that have the specified name
51 $charName = mysqli_real_escape_string($link, $_POST['charName']);
52 $query = "select char_id, char_name from characters where char_name = '$charName'";
53 $result = mysqli_query($link, $query) or die ("Can't execute the query: ".$query);
55 if (mysqli_num_rows($result) == 0)
57 echo "<h1>Can't find the character ".$_POST["charName"]."<h1>";
61 $row = mysqli_fetch_assoc($result);
62 $currentSession = $row['char_id'];
63 $currentchar = $row['char_name'];
65 // send the invitation info to the session manager
66 $invitePioneer = new InvitePioneerCb
;
68 $invitePioneer->connect($RSMHost, $RSMPort, $res);
69 // $rsmProxy = new CRingSessionManagerWebProxy;
71 // TODO: not sure it works with a char slot > 0
72 $invitePioneer->inviteCharacter(($userId*16) +
getCharSlot(), $_POST["sessionId"], $row[0], $_POST["mode"]);
74 echo "wait result...";
75 // wait the the return message
76 // $rsmSkel = new CRingSessionManagerWebSkel;
77 if (!$invitePioneer->waitCallback())
78 echo "<h2>No response from server</h2><br>";
80 echo "Result received...";
85 // buid a form to gather info about the character to invite
87 echo "<h1>Invite a player in the session ".$_POST["sessionId"]."</h1>";
88 echo "<form action='invite_pioneer.php' method='post'>Type in character name:<br>";
89 echo "<input type='text' name='charName' value=''>";
90 echo "<input type='submit' name='button' value='Invite'>";
91 echo "<input type='hidden' name='sessionId' value='".$_POST["sessionId"]."'>";
92 echo "<input type='hidden' name='mode' value='".$_POST["mode"]."'>";
93 echo "<input type='hidden' name='execute'>";
99 <p
><a href
="web_start.php">Return to main
</a
></p
>