Calling #WriteAsync from Websocket
I don't know if you guys can help me with this problem, but this is my last resort. I use your package in my MAUI project. When I call the #WriteAsync method in the MainPage, everything works without problems.
But now to my obstacle: I also use the Websocket.Client package. I want to listen to the websocket and send the news via BLE whenever there is a change. But now when I call the #WriteAsync method in the websocket, nothing happens, the data is not sent. Here is the code example:
public void StartWebsocket(ICharacteristic characteristic)
{
try
{
var exitEvent = new ManualResetEvent(false);
var url = new Uri("wss://xy.zz/v1/socket");
using var client = new WebsocketClient(url);
client.ReconnectTimeout = TimeSpan.FromSeconds(30);
client.ReconnectionHappened.Subscribe(info =>
{
Console.WriteLine("Reconnection happened, type: " + info.Type);
});
client.MessageReceived.Subscribe(msg =>
{
Console.WriteLine("Message received: " + msg);
if (msg.ToString().ToLower() == "{}")
{
string data = "{\"op\":\"authenticate\", \"token\":\"" + key + "\"}";
client.Send(data);
}
characteristic.WriteAsync(Encoding.ASCII.GetBytes(msg));
});
client.Start();
exitEvent.WaitOne();
}
catch (Exception ex)
{
Console.WriteLine("ERROR: " + ex.ToString());
}
}
I can use every other Websocket implementations, if you have better experiences!
Configuration
Version of the Plugin: 3.0.0-beta.4
Platform: Android 10.0 - API 29
Device: Sony H8324
Hi @EscolarProgramming,
I'm the friendly issue checker. It seems like (50.00 %) you haven't used our issue template :cry: I think it is very frustrating for the repository owners, if you ignore them.
If you think it's fine to make an exception, just ignore this message. But if you think it was a mistake to delete the template, please close the issue and create a new one.
Thanks!