C
C#2y ago
EnoPM

❔ Socket connection in WPF application

Hello, I'm fairly new to the C# environment and there's something I can't figure out: I created a console application in which I manage to connect correctly to my local socket.io server. I can also send and receive events. However, in my WPF application, using the same library and the same code, I can send events but I don't receive any (not even the onConnected). I must be missing a step or something obvious but I can't find it.
3 Replies
EnoPM
EnoPMOP2y ago
My console application code :
internal static class Program
{
internal static void Main(string[] args)
{
Console.WriteLine("Hello World");
SocketClient();
while (true) { }
}

private static async void SocketClient()
{
var socket = new SocketIO("http://localhost:3000/tools");
socket.OnConnected += (sender, args) =>
{
Console.WriteLine("Connected!");
};
socket.OnAny((name, response) =>
{
Console.WriteLine(name);
});
await socket.ConnectAsync();
socket.On("bor.tools.login.response", response =>
{
Console.WriteLine($"server.response: {response.GetValue<string>()}");
});
await socket.EmitAsync("bor.tools.login", "email", "password");
}
}
internal static class Program
{
internal static void Main(string[] args)
{
Console.WriteLine("Hello World");
SocketClient();
while (true) { }
}

private static async void SocketClient()
{
var socket = new SocketIO("http://localhost:3000/tools");
socket.OnConnected += (sender, args) =>
{
Console.WriteLine("Connected!");
};
socket.OnAny((name, response) =>
{
Console.WriteLine(name);
});
await socket.ConnectAsync();
socket.On("bor.tools.login.response", response =>
{
Console.WriteLine($"server.response: {response.GetValue<string>()}");
});
await socket.EmitAsync("bor.tools.login", "email", "password");
}
}
EnoPM
EnoPMOP2y ago
My WPF application code:
Accord
Accord2y ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server