doghappy / socket.io-client-csharp

socket.io-client implemention for .NET
MIT License
729 stars 125 forks source link

Sample project closes when sending from client to server #256

Closed asheroto closed 2 years ago

asheroto commented 2 years ago

When running SocketIOClient.Sample straight from the current repo, I can receive messages from the server, but if I type anything and hit enter, the program exits with code 0.

<program path> (process 11212) exited with code 0.

No debugging info for some reason either...

It's Visual Studio 2022 targeting .NET 6. I tried .NET 5 but same issue.

doghappy commented 2 years ago

The Sample program does not send user input to the server.

You can find these two lines of code in Main:

await socket.ConnectAsync();
Console.ReadLine();

Console.ReadLine() is just to keep the program running, when you hit Enter, the program is done executing, so you get a normal exit code of 0

In Socket_OnConnected I use hardcoding to send data to the server.

asheroto commented 2 years ago

Ah, I see. How can I keep the program running indefinitely?

doghappy commented 2 years ago

After the sample program runs, do not press the Enter key. You can open a new shell window if you want

asheroto commented 2 years ago

Thanks