I have websocket listner in this way in JavaScript.
var connectionLostMessage = null;
function websocketConnect() {
var conn = new ab.Session('ws://abc.xyz.dd:8080?time=1627624930.3964',
function () {
clearTimeout(connectionLostMessage);
connectionLostMessage = null;
conn.subscribe('316627', function (topic, data) {
//some code to use data display
});
},
function () {
//When connection fails
//Connection fail handling
setTimeout(function () {
websocketConnect();
}, 1000)
},
{'skipSubprotocolCheck': true}
);
}
websocketConnect();
I want to connect and subscribe to the channel using c# as found in JavaScript in following line.
conn.subscribe('316627', function (topic, data) {
I have tried with in this way but unable to subscribe in the way above.
public async Task WebsocketClientTest()
{
var url = new Uri("ws://abc.xyz.dd:8080");
var exitEvent = new ManualResetEvent(false);
using (var client = new WebsocketClient(url))
{
client.MessageReceived
.Subscribe(msg => Console.WriteLine($"msg.Text: {msg.Text}, msg.MessageType: {msg.MessageType}"));
await client.Start();
exitEvent.WaitOne();
}
Console.ReadLine();
}
I need to write a console application in .Net Core. Please suggest any help or third party compatible with .Net Core 3.1
Many thanks!