예제 #1
0
<?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 '网络不行,超时';
}
예제 #2
0
 public function send($message)
 {
     static $channel_instance = null;
     if (empty($channel_instance)) {
         $channel_instance = new SaeChannel();
     }
     $channel_instance->sendMessage($this->_connection_identifier, $message);
 }
예제 #3
0
<?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}";
}
예제 #4
0
 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]);
 }
예제 #5
0
<?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';