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'; } }
if(url.indexOf("?") == -1) return {}; var params = url.substring(url.indexOf("?")+1).split("&"); 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; ?> ');
<?php /* *发送数据端并等待数据返回显示 *放sinaapp上 * */ header("Content-type: text/html; charset=utf-8"); echo microtime() . "<br>"; $channel = new SaeChannel(); $con = urlencode("Hi.DemoSend"); $ret = $channel->sendMessage('demoChannel', $con); $mmc = memcache_init(); if ($mmc == false) { echo "mc init failed\n"; } else { for ($i = 0; $i < 6; $i++) { sleep(1); try { $ret = memcache_get($mmc, "key"); if (strlen($ret) > 0) { echo 'Hi.DemoSend_' . urldecode($ret); echo "<br>" . microtime(); exit; } } catch (Exception $e) { print $e->getMessage(); } } echo '网络不行,超时'; }
<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,
$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->create_channel($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 $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}')"); }
public function send($message) { static $channel_instance = null; if (empty($channel_instance)) { $channel_instance = new SaeChannel(); } $channel_instance->sendMessage($this->_connection_identifier, $message); }
header("Content-type: text/html; charset=utf-8"); 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
function apido() { if (!isset($_REQUEST['request']) || !($request = unserialize($_REQUEST['request']))) { return send_error(ARGS_ERROR, 'request can\'t empty'); } $source = $request['source']; if (strlen($source) < 1) { return send_error(ARGS_ERROR, 'source can\'t empty'); } if (!isset($GLOBALS['config']['whois'][$source]) || strlen($GLOBALS['config']['whois'][$source]) < 1) { return send_error(ARGS_ERROR, 'bad source id'); } $data = $request['data']; if (strlen($data) < 1) { return send_error(ARGS_ERROR, 'data can\'t empty'); } $ckeys = z(t($request['ckeys'])); if (strlen($ckeys) < 1) { $ckey_array = array("everything"); } else { $ckey_array = array("everything"); $keys = explode(',', $ckeys); if (is_array($keys)) { $ckey_array = array_merge($keys, $ckey_array); } } $action = v('action'); if (strlen($action) < 1) { $action = "display"; } $timeline = date("Y-m-d H:i:s"); // create channel $channel = new SaeChannel(); $mc = memcache_init(); $channel_name = 'nowboard-url-all'; if ($action == 'display') { $data = z(t($data)); } if ($url = $mc->get($channel_name)) { foreach ($ckey_array as $ckey) { $message = array('ckey' => $ckey, 'data' => $data, 'action' => $action, 'timeline' => $timeline, 'source' => $GLOBALS['config']['whois'][$source]); $channel->sendMessage($channel_name, json_encode($message)); } } /* if( is_array(c('talkman')) ) { foreach( c('talkman') as $uid ) { $channel_name = 'nowboard-url-'.$uid; if( $action == 'display' ) $data = z(t($data)); if( $url = $mc->get($channel_name) ) { foreach( $ckey_array as $ckey ) { $message = array( 'ckey' => $ckey , 'data' => $data , 'action' => $action , 'timeline' => $timeline , 'source' => $GLOBALS['config']['whois'][$source] ); $channel->sendMessage( $channel_name , json_encode($message) ); } } } } */ return send_result('send data to * # ' . $ckeys . ' from ' . $GLOBALS['config']['whois'][$source]); }
<?php if (class_exists('SaeChannel')) { $channel = new SaeChannel(); $msg = $_REQUEST['message']; $to = isset($_REQUEST['to']) ? $_REQUEST['to'] : 'publicChannel'; $to = trim($to); $to = $to == "" ? 'publicChannel' : $to; $ret = $channel->sendMessage($to, $msg); echo "send messageret:{$msg} to {$to} <br />{$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';