当前位置: 首页>>代码示例>>PHP>>正文


PHP Server::start方法代码示例

本文整理汇总了PHP中Server::start方法的典型用法代码示例。如果您正苦于以下问题:PHP Server::start方法的具体用法?PHP Server::start怎么用?PHP Server::start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Server的用法示例。


在下文中一共展示了Server::start方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: hproseserver_call

function hproseserver_call(swoole_process $worker)
{
    define('APPLICATION_PATH', dirname(__DIR__) . "/application");
    define('MYPATH', dirname(APPLICATION_PATH));
    $application = new Yaf_Application(dirname(APPLICATION_PATH) . "/conf/application.ini");
    $application->bootstrap();
    $config_obj = Yaf_Registry::get("config");
    $hprose_config = $config_obj->hprose->toArray();
    $server = new Server("tcp://" . $hprose_config['ServerIp'] . ":" . $hprose_config['port']);
    $server->setErrorTypes(E_ALL);
    $server->setDebugEnabled();
    $server->addFunction('zys');
    $server->start();
}
开发者ID:qieangel2013,项目名称:zys,代码行数:14,代码来源:server.php

示例2: onTask

        echo "Client {$fd} close connection\n";
    }
    public function onTask($serv, $task_id, $from_id, $data)
    {
        $data_arr = json_decode($data, true);
        $source_data = $data_arr['source'];
        $source = explode(' ', $source_data);
        $trainid = $source[1];
        $command = './tools/preprocess.py --id ' . $trainid;
        exec($command);
        return "Task {$task_id}'s result";
    }
    public function onFinish($serv, $task_id, $data)
    {
    }
    /**
     * send message by swoole
     * @param string $content the command
     * return boolean true if shut down the swoole_client successfully
     */
    private function sendtagbyswoole($content)
    {
        $client = new swoole_client(SWOOLE_SOCK_TCP, SWOOLE_SOCK_SYNC);
        $client->connect('127.0.0.1', 8888, 0.5, 0);
        $client->send($content);
        return $client->close();
    }
}
$server = new Server();
$server->start();
开发者ID:CptSteven,项目名称:faster-rcnn-mod,代码行数:30,代码来源:train.php

示例3: curl_setopt_array

<?php

namespace Ftob\LeaderBoardBundle\Tests;

require __DIR__ . '/../vendor/autoload.php';
require __DIR__ . '/Server.php';
Server::start();
register_shutdown_function(function () {
    Server::stop();
});
// Override curl_setopt_array() to get the last set curl options
namespace GuzzleHttp\Handler;

function curl_setopt_array($handle, array $options)
{
    if (!empty($_SERVER['curl_test'])) {
        $_SERVER['_curl'] = $options;
    } else {
        unset($_SERVER['_curl']);
    }
    \curl_setopt_array($handle, $options);
}
开发者ID:ftob,项目名称:php-leaderboard-bundle,代码行数:22,代码来源:bootstrap.php

示例4: onFinish

     */
    public function onFinish($server, $task_id, $data)
    {
    }
    /**
     * 用户关闭连接
     * @param $server
     * @param $fd
     */
    public function onClose($server, $fd)
    {
        echo "{$fd} closed" . PHP_EOL;
        $username = $this->clients[$fd];
        //释放客户,利用锁进行数据同步
        $this->lock->lock();
        unset($this->clients[$fd]);
        $this->lock->unlock();
        //有用户名的用户则推送离开消息
        if (!empty($username)) {
            $frame = new stdClass();
            $frame->fd = $fd;
            $frame->data = array('username' => $username, 'message' => $username . '离开聊天室', 'type' => 1, 'status' => 1, 'time' => date('H:i:s'));
            $frame->clients = $this->clients;
            // 发送离开消息
            $server->task($frame);
        }
    }
}
$Server = new Server();
$Server->start();
开发者ID:kong36088,项目名称:ChatRoom,代码行数:30,代码来源:server.php

示例5: Server

<?php

require __DIR__ . '/Server.php';
$setting = (require __DIR__ . '/config.php');
$host = array_shift($setting);
$port = array_shift($setting);
$serv = new Server($host, $port, $setting);
$serv->start();
开发者ID:wuxw,项目名称:swala,代码行数:8,代码来源:startup.php

示例6: json_decode

        $this->data = json_decode(file_get_contents('php://input'), true);
        // Раскодируем JSON
        // Подключаемся к базе данных
        $this->conn = new mysqli(self::SQL_SERVER, self::SQL_USER, self::SQL_PASS, self::SQL_DB);
        if ($this->conn->connect_error) {
            if (DEBUG) {
                die('Ошибка соединения: ' . mysql_error());
            }
        }
    }
    private function __destruct()
    {
        // Закрываем соединение с базой
        $this->conn->close();
    }
    // Задаем значение в базе данных
    private function setValue($value_name, $value_text)
    {
        return $this->conn->query('UPDATE ajax_table SET value_text = \'' . $value_text . '\' WHERE value_name = \'' . $value_name . '\'');
    }
    // Получаем значение из базы данных
    private function getValue($value_name)
    {
        $res = $this->conn->query("SELECT value_text FROM ajax_table WHERE value_name='{$value_name}'");
        $row = $res->fetch_object();
        return $row->value_text;
    }
}
// Server::start()->process()->display();
Server::start()->process()->result();
开发者ID:Alekzandero,项目名称:AJAX-Study,代码行数:30,代码来源:server.php

示例7: array

#!/usr/bin/php -q
<?php 
require_once 'light/Server.php';
require_once 'light/JsonEncoder.php';
error_reporting(E_ALL);
set_time_limit(0);
ob_implicit_flush();
$args = $_SERVER['argv'];
$flags = array();
foreach ($args as $arg) {
    if (preg_match('/^-/', $arg)) {
        $flags[preg_replace('/^-/', '', $arg)] = true;
    }
}
if (empty($args[1]) || empty($args[2])) {
    echo "\nUsage: xmlserver.php HOSTIP PORT (-log)\n";
    exit;
}
$ip = $args[1];
$port = $args[2];
Message::$encoder = new JsonEncoder();
$mySocketServer = new Server($ip, $port);
$mySocketServer->start();
开发者ID:seanhess,项目名称:shared-model-server,代码行数:23,代码来源:server.php

示例8: stdClass

        $x2 = new stdClass();
        /*
        $a = require 'req01.php';
        $b = require 'req02.php';
        $c = require 'req03.php';
        $d = require 'req04.php';
        */
        $GLOBALS['this']->test = 'test';
        $GLOBALS['this']->x1 = $x1;
        $GLOBALS['this']->x2 = $x2;
        //var_dump(array_keys($GLOBALS));
        var_dump(get_class($GLOBALS['this']));
        usleep(10000);
        echo PHP_EOL . '[Application] dumping $GLOBALS[\'server\']:' . PHP_EOL;
        var_dump($GLOBALS['server']);
        usleep(10000);
        echo PHP_EOL . '[Application] dumping $GLOBALS[\'this\']:' . PHP_EOL;
        var_dump($GLOBALS['this']);
    }
}
$a = [];
for ($i = 0; $i < 100; $i++) {
    $a[] = new stdClass();
}
$server = new Server();
$server->start(PTHREADS_INHERIT_ALL | PTHREADS_ALLOW_GLOBALS);
usleep(5000);
echo PHP_EOL . '[GLOBAL] dumping $server:' . PHP_EOL;
$server->x1 = 'asdf';
var_dump($server);
echo "finished script..." . PHP_EOL;
开发者ID:appserver-io-lab,项目名称:globals-require-test,代码行数:31,代码来源:run.php


注:本文中的Server::start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。