dropr_Client_Peer_Abstract::getInstance PHP Method

getInstance() public static method

Singleton-Factory for Peer-Instances
public static getInstance ( string $method, string $url = false ) : dropr_Client_Peer_Abstract
$method string
$url string
return dropr_Client_Peer_Abstract
    public static function getInstance($method, $url = false)
    {
        if ($url === false) {
            if (!(list($method, $url) = explode(';', $method))) {
                throw new dropr_Client_Exception("Could not explode method and url from '{$method}'");
            }
        }
        $key = $method . ';' . $url;
        if (!isset(self::$instances[$key])) {
            // Guess the classname from transport method
            $className = 'dropr_Client_Peer_' . ucfirst($method);
            self::$instances[$key] = new $className($method, $url);
        }
        return self::$instances[$key];
    }

Usage Example

Ejemplo n.º 1
0
 public function testPut()
 {
     $peer = dropr_Client_Peer_Abstract::getInstance('HttpUpload', 'http://localhost/droprserver/');
     $dt = time();
     $i = 0;
     // $m = $this->createMessage(1000);
     $m = "ich bin eine test message von " . date("H:m:i");
     while ($i < 1) {
         $msg = $this->queue->createMessage($m, $peer);
         $msg->queue();
         $i++;
         echo '.';
     }
     $dt = time() - $dt;
     echo $dt . "\n";
     echo "\n\n";
 }
All Usage Examples Of dropr_Client_Peer_Abstract::getInstance