Subscribing to the Channel
Once the connection is established, you can send a subscription request to the server, requesting to subscribe to a specific channel (e.g., UserBalanceChannel).
socket.onopen = function() {
socket.send(JSON.stringify({
command: 'subscribe',
identifier: JSON.stringify({
channel: 'UserBalanceChannel'
}),
}));
};
After successfully subscribing, you will receive a confirmation message
{
"identifier": "{"channel":"UserBalanceChannel"}",
"type": "confirm_subscription"
}
This message confirms that you have successfully subscribed to the UserBalanceChannel and are now receiving updates.