websocket-client icon indicating copy to clipboard operation
websocket-client copied to clipboard

Can this handle channel subscribing like Phoenix js

Open Cookiezzz opened this issue 2 years ago • 1 comments

Hi there. Awesome library. Use it for a simple websocket and works great! Now I see in the help files you talk about channels and subscribing but I don't see the actual way on how to. Is it possible to subscribe to channels in a web socket like Phoenix does? https://hexdocs.pm/phoenix/js/index.html

Cookiezzz avatar May 06 '22 18:05 Cookiezzz

yes you can.

async Task JoinChannel(ClientWebSocket webSocket, string channelName)
{
    string joinMessage = $"{{\"topic\":\"{channelName}\",\"event\":\"phx_join\",\"payload\":{{}},\"ref\":\"1\"}}";

    await SendMessage(webSocket, joinMessage);
}

marek-petak avatar Jan 10 '24 09:01 marek-petak