Important
We are updating the images for OroCommerce version 6.1 to align with the latest changes in the back-office design. During this transition, some images may still show older versions. Thank you for your patience as we work to update all visuals to reflect these changes.
Client
OroSyncBundle provides a WebSocket client oro_sync.websocket_client, which in its turn is based on
Gos WebSocketClient component Gos\Component\WebSocketClient\Wamp\Client
.
WebSocket client uses Sync authentication tickets mechanism, so you do not have to worry about authentication on the backend side. WebSocket client oro_sync.websocket_client uses anonymous Sync authentication tickets, so when you connect to the WebSocket server, it treats you as if you are anonymous.
Publish Messages
You can publish messages to channels using the publish() method of the WebSocket client, for example.
$websocketClient = $this->get('oro_sync.websocket_client');
$websocketClient->publish('oro/custom-channel', ['foo' => 'bar']);
Checker
It is strongly recommended to use connection checker oro_sync.client.connection_checker
before trying to connect or publish to the WebSocket server, e.g.:
$websocketConnectionChecker = $this->get('oro_sync.client.connection_checker');
if ($websocketConnectionChecker->checkConnection()) {
$websocketClient = $this->get('oro_sync.websocket_client');
$websocketClient->publish('oro/custom-channel', ['foo' => 'bar']);