Beispiel #1
0
 public function testConstruct()
 {
     $channel1 = new Channel('NAME1');
     $this->assertEquals('NAME1', $channel1->getName());
     $this->assertEquals('r', $channel1->getPermission());
     $channel2 = new Channel('NAME_2', Channel::PERMISSION_WRITE);
     $this->assertEquals('NAME_2', $channel2->getName());
     $this->assertEquals('w', $channel2->getPermission());
 }
Beispiel #2
0
require_once '../vendor/autoload.php';
$ortcConfig = new OrtcConfig();
$ortcConfig->setApplicationKey('YOUR_APPLICATION_KEY');
$ortcConfig->setPrivateKey('YOUR_PRIVATE_KEY');
$ortcConfig->setVerifySsl(false);
$authToken = 'YOUR_AUTHENTICATION_TOKEN';
$channels = [];
$testChannel = new Channel();
$testChannel->setName('CHANNEL_NAME');
$testChannel->setPermission(Channel::PERMISSION_WRITE);
$channels[] = $testChannel;
$ortc = new Ortc($ortcConfig);
if (isset($_POST['message'])) {
    $sendMessageRequest = new SendMessageRequest();
    $sendMessageRequest->setAuthToken($authToken);
    $sendMessageRequest->setChannelName($testChannel->getName());
    $sendMessageRequest->setMessage($_POST['message']);
    $ortc->sendMessage($sendMessageRequest);
} else {
    $authRequest = new AuthRequest();
    $authRequest->setAuthToken($authToken);
    $authRequest->setExpireTime(5 * 60);
    $authRequest->setPrivate(true);
    $authRequest->setChannels($channels);
    $authResponse = $ortc->authenticate($authRequest);
}
?>
<!doctype html>
<html>
<head>
    <title>Send Message</title>
Beispiel #3
0
$authRequest = new AuthRequest();
$authRequest->setAuthToken($authToken);
$authRequest->setExpireTime(61);
$authRequest->setPrivate(true);
$authRequest->setChannels($channels);
$authResponse = $ortc->authenticate($authRequest);
?>
<!doctype html>
<html>
<head>
    <title></title>
</head>
<body>
<input type="text" id="message"/>
<input type="button" onclick="sendMessage('<?php 
echo $testChannel->getName();
?>
');" value="Send to myChannel"/>

<div id="log"></div>

<script src="http://code.xrtml.org/xrtml-3.0.0.js"></script>
<script>
    var appkey = '<?php 
echo $ortcConfig->getApplicationKey();
?>
',
        url = '<?php 
echo $url;
?>
',