websocket DSN params
This commit is contained in:
@@ -38,6 +38,8 @@ class ZeroMQSender implements Sender
|
||||
{
|
||||
private $config;
|
||||
|
||||
private const DSN = 'tcp://localhost:5555';
|
||||
|
||||
public function __construct(Config $config)
|
||||
{
|
||||
$this->config = $config;
|
||||
@@ -45,18 +47,15 @@ class ZeroMQSender implements Sender
|
||||
|
||||
public function send(string $message): void
|
||||
{
|
||||
$dsn = $this->config->get('webSocketSubmissionDsn', 'tcp://localhost:5555');
|
||||
$dsn = $this->config->get('webSocketZeroMQSubmissionDsn') ?? self::DSN;
|
||||
|
||||
$context = new ZMQContext();
|
||||
|
||||
$socket = $context->getSocket(ZMQ::SOCKET_PUSH, 'my pusher');
|
||||
|
||||
$socket->connect($dsn);
|
||||
|
||||
$socket->send($message);
|
||||
|
||||
$socket->setSockOpt(ZMQ::SOCKOPT_LINGER, 1000);
|
||||
|
||||
$socket->disconnect($dsn);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,23 +29,33 @@
|
||||
|
||||
namespace Espo\Core\WebSocket;
|
||||
|
||||
use React\{
|
||||
EventLoop\LoopInterface,
|
||||
ZMQ\Context as ZMQContext,
|
||||
};
|
||||
use Espo\Core\Utils\Config;
|
||||
|
||||
use React\EventLoop\LoopInterface;
|
||||
use React\ZMQ\Context as ZMQContext;
|
||||
|
||||
use ZMQ;
|
||||
|
||||
class ZeroMQSubscriber implements Subscriber
|
||||
{
|
||||
private $config;
|
||||
|
||||
private const DSN = 'tcp://127.0.0.1:5555';
|
||||
|
||||
public function __construct(Config $config)
|
||||
{
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
public function subscribe(Pusher $pusher, LoopInterface $loop): void
|
||||
{
|
||||
$dsn = $this->config->get('webSocketZeroMQSubscriberDsn') ?? self::DSN;
|
||||
|
||||
$context = new ZMQContext($loop);
|
||||
|
||||
$pull = $context->getSocket(ZMQ::SOCKET_PULL);
|
||||
|
||||
$pull->bind('tcp://127.0.0.1:5555');
|
||||
|
||||
$pull->bind($dsn);
|
||||
$pull->on('message', [$pusher, 'onMessageReceive']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,6 +116,8 @@ return [
|
||||
'webSocketSslAllowSelfSigned',
|
||||
'webSocketUseSecureServer',
|
||||
'webSocketPort',
|
||||
'webSocketZeroMQSubscriberDsn',
|
||||
'webSocketZeroMQSubmissionDsn',
|
||||
'actualDatabaseType',
|
||||
'actualDatabaseVersion',
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user