function get_channel_url($uid = null) { if (!is_login()) { return false; } /* $channel = new SaeChannel(); $channel_name = 'NowBoard'; $duration = 3600; $url = $channel->createChannel( wbuid().'.'.$channel_name,$duration); */ if ($uid == null) { $uid = wbuid(); } $urlkey = 'nowboard-url-all'; $mc = memcache_init(); if (!($url = $mc->get($urlkey))) { $channel = new SaeChannel(); $channel_name = $urlkey; $duration = 3600; $url = $channel->createChannel($channel_name, $duration); $mc->set($urlkey, $url, 0, 3600); } return $url; }
public function index() { if (defined("SAE_TMP_PATH")) { //Channel $client_id = md5(uniqid(mt_rand(0, 9999999999))); $channel_instance = new SaeChannel(); $token = $channel_instance->createChannel($client_id); echo $token; } else { //WebSocket echo 'ws://' . $_SERVER['HTTP_HOST'] . ':9090/pubsub'; } }
var obj = {}; for(var i in params){ var pair = params[i].split("="); var key = decodeURIComponent(pair[0]); var value = decodeURIComponent(pair[1]); obj[key] = value; } return obj; })(); <?php $channel = new SaeChannel(); //$user = '******'.rand(1000,100000); //$privateCh = $channel->createChannel($user,60); $publicCh = $channel->createChannel('publicChannel', 60); ?> var $msg; var privateChannel = '<?php echo $user; ?> '; publicSocket = new sae.Channel('<?php echo $publicCh; ?> '); publicSocket.onopen = function(){ console.log('publicChannel' + " opened");
<div class="x-hide-display" id="homepageChartContainer"> </div> <div class="x-hide-display" id="completeProcess"> </div> <div id="mytaskCompleteProcess" class="x-hide-display"> </div> <?php if (class_exists("SaeChannel")) { $channel = new SaeChannel(); $privateChannel = $channel->createChannel("sae_channel_" . $_SESSION["name"], 60 * 60 * 24); } else { $privateChannel = null; } ?> <script type="text/javascript"> var privateChannel = '<?php echo $privateChannel; ?> '; Ext.define('User', { singleton: true, name: '<?php
<?php $channel = new SaeChannel(); $name = 'user' . time() . '-' . rand(0, 10000); $duration = 3600; $url = $channel->createChannel($name, $duration); $mysql = new SaeMysql(); $sql = "SELECT name FROM online LIMIT 1"; $sqlback = $mysql->getData($sql); if ($sqlback[0]['name']) { $to = $sqlback[0]['name']; $mysql->runSql("delete from online where name='{$to}'"); } else { $mysql->runSql("insert into online(name) values('{$name}')"); }
if (!empty($_POST['con'])) { $mmc = memcache_init(); if ($mmc == false) { echo "mc init failed\n"; } else { try { memcache_set($mmc, "key", $_POST['con']); } catch (Exception $e) { print $e->getMessage(); } echo "ok"; } exit; } $channel = new SaeChannel(); $connection = $channel->createChannel('demoChannel', 12 * 3600); ?> <!DOCTYPE html> <html lang="zh-cn"> <head> <meta charset="UTF-8" /> <script type="text/javascript" src="http://lib.sinaapp.com/js/jquery/2.0.3/jquery-2.0.3.min.js"></script> <script type="text/javascript" src="http://channel.sinaapp.com/api.js"></script> </head> <body> <div id="s2"></div> <div id="s3"></div> </body> <script> var socket = new sae.Channel('<?php echo $connection;
$user = $_COOKIE['u']; if (!$user) { $user = uniqid(); setcookie("u", $user); } $game_key = $_REQUEST['g']; if (!$game_key) { $game_key = $user; $stor_mess = array('userX' => $user, 'userO' => null, 'board' => str_repeat(" ", 9), 'moveX' => true, 'winner' => null, 'winning_board' => null); $game = new Game($game_key, $stor_mess); $game->put(); } else { $game = Game::get_by_key_name($game_key); if (!$game->userO) { $game->userO = $user; $game->put(); } } $game_link = '/?g=' . $game_key; if ($game) { $channel_instance = new SaeChannel(); $token = $channel_instance->createChannel($user . $game_key); $game_update_instance = new GameUpdater($game); $initial_message = $game_update_instance->get_game_message(); } else { die('No such game'); } $render_message = array('token' => $token, 'me' => $user, 'game_key' => $game_key, 'game_link' => $game_link, 'initial_message' => $initial_message); $template_file = 'index.tpl'; $ret = render_template($template_file, $render_message); echo $ret;
<?php header("Content-type: text/html; charset=utf-8"); $channel = new SaeChannel(); $connection = $channel->createChannel('test', 3600); $message_content = 'qwgxiaoxiao'; $ret = $channel->sendMessage('test', $message_content); include 'test.html';