public static function create($context, $type, LoggerInterface $logger = null, $persistentId = null, $onNewSocket = null)
    {
        if (!is_callable($onNewSocket)) {
            $onNewSocket = null;
        }

        $newSocket = false;
        $callback = function() use ($onNewSocket, &$newSocket) {
            $newSocket = true;
            if ($onNewSocket !== null) {
                $onNewSocket();
            }
        };

        $instance = new self($context, $type, $persistentId, $callback);
        $instance->setId(self::$nextId);
        $instance->setNewSocket($newSocket);
        $instance->setSockOpt(ZMQ::SOCKOPT_LINGER, 0);
        self::$nextId++;

        if (null !== $logger) {
            $instance->setLogger($logger);
        }

        return $instance;
    }
public static function create($context, $type, LoggerInterface $logger = null, $persistentId = null, $onNewSocket = null)
    {
        if (!is_callable($onNewSocket)) {
            $onNewSocket = null;
        }

        $newSocket = false;
        $callback = function() use ($onNewSocket, &$newSocket) {
            $newSocket = true;
            if ($onNewSocket !== null) {
                $onNewSocket();
            }
        };

        $instance = new self($context, $type, $persistentId, $callback);
        $instance->setId(self::$nextId);
        $instance->setNewSocket($newSocket);
        $instance->setSockOpt(ZMQ::SOCKOPT_LINGER, 0);
        self::$nextId++;

        if (null !== $logger) {
            $instance->setLogger($logger);
        }

        return $instance;
    }
public static function create ( $ context , $ type , LoggerInterface $ logger = null , $ persistentId = null , $ onNewSocket = null ) { if ( ! is_callable ( $ onNewSocket ) ) { $ onNewSocket = null ; } $ newSocket = false ; $ callback = function ( ) use ( $ onNewSocket , & $ newSocket ) { $ newSocket = true ; if ( $ onNewSocket !== null ) { $ onNewSocket ( ) ; } } ; $ instance = new self ( $ context , $ type , $ persistentId , $ callback ) ; $ instance -> setId ( self :: $ nextId ) ; $ instance -> setNewSocket ( $ newSocket ) ; $ instance -> setSockOpt ( ZMQ :: SOCKOPT_LINGER , 0 ) ; self :: $ nextId ++ ; if ( null !== $ logger ) { $ instance -> setLogger ( $ logger ) ; } return $ instance ; }
Create a new Socket.

@param \ZMQContext     $context      The Context to create this Socket with
@param integer         $type         One of the ZMQ::SOCKET_{PUB,SUB,PUSH,PULL,REQ,REP,ROUTER,DEALER} contants.
@param LoggerInterface $logger       A Logger
@param string          $persistentId When using a persistent socket: the persistence ID
@param callable|null   $onNewSocket  Callback to use when a new socket is created

@return \AlphaRPC\Common\Socket\Socket
Create a new Socket .