ModelsConcurrent.php 980 Bytes
<?php

/**
 * Created by PhpStorm.
 * User: Zip
 * Date: 14/11/27
 * Time: 下午1:10
 */
namespace LibModels;

use Hood\Concurrent as hoodConcurrent;

class ModelsConcurrent
{
    static protected $uri = 'http://service.example.yohobuy.com/service/product/v1';

    /**
     * @var Concurrent|Concurrent\Yar\Concurrent
     */
    static private $concurrent;


    /**
     * @return Concurrent|Concurrent\Yar\Concurrent
     */
    static protected function connect()
    {
        if (empty(self::$concurrent)) {
            self::$concurrent = hoodConcurrent::yarConcurrent(self::$uri);
        }
        return self::$concurrent;
    }

    static public function loop()
    {
        self::connect()->loop('Models\ModelsConcurrent::callback', 'Models\ModelsConcurrent::errorCallback');
    }

    static public function errorCallback($type, $error, $callinfo)
    {
        print_r($error);
    }

    static public function callback($ret, $callinfo)
    {
        
    }
}