Skip to content
This repository was archived by the owner on Aug 24, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/Broadcasting/Broadcaster/ZmqBroadcaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,22 @@ public function validAuthenticationResponse($request, $result)
'user_info' => $result,
]]);
}

/**
* Authenticate the incoming request for a given channel.
* Make this function available from external calls
*
* @param \Illuminate\Http\Request $request
* @param string $channel
* @return mixed
*
* @throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException
*/
public function verifyUserCanAccessChannel($request, $channelName)
{
return parent::verifyUserCanAccessChannel(
$request,
$channelName
);
}
}
14 changes: 14 additions & 0 deletions src/Connector/ZmqConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,30 @@ abstract class ZmqConnector
{
protected $connection;

/**
* @var \ZMQContext
*/
public $socket;

public function __construct($connection)
{
$this->connection = $connection;
$this->socket = $this->connect();
}

/**
* @return \ZMQSocket
*/
abstract public function connect();

public function getSocket()
{
if(is_null($this->socket)) {
$this->socket = $this->connect();
}
return $this->socket;
}

protected function dsn()
{
return \Config::get(sprintf('zmq.connections.%s.dsn', $this->connection), 'tcp://127.0.0.1:5555');
Expand Down
2 changes: 1 addition & 1 deletion src/Connector/ZmqPublish.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function __construct($connection = 'publish')
*/
public function connect()
{
$context = new \ZMQContext();
$context = new \ZMQContext(1, true);
$socket_method = \Config::get(sprintf('zmq.connections.%s.method', $this->connection), \ZMQ::SOCKET_PUB);
$socket = $context->getSocket($socket_method);
$socket->connect($this->dsn());
Expand Down
3 changes: 1 addition & 2 deletions src/Zmq.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,11 @@ public function __construct(array $connections = [])
*/
public function connection($connection = null)
{

if (! $connection) {
$connection = \Config::get('zmq.default');
}

return \App::make(sprintf('zmq.connection.%s', $connection))->connect();
return \App::make(sprintf('zmq.connection.%s', $connection))->socket;
}

/**
Expand Down