Marfusios / websocket-client

🔧 .NET/C# websocket client library
MIT License
692 stars 127 forks source link

Can this handle channel subscribing like Phoenix js #110

Open Cookiezzz opened 2 years ago

Cookiezzz commented 2 years ago

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

marek-petak commented 9 months ago

yes you can.

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

    await SendMessage(webSocket, joinMessage);
}