EnoPM
EnoPM
CC#
Created by EnoPM on 5/19/2023 in #help
❔ Socket connection in WPF application
4 replies
CC#
Created by EnoPM on 5/19/2023 in #help
❔ Socket connection in WPF application
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");
}
}
4 replies