Halt execution until server/client is ready after calling start
See original GitHub issueIs there a way to block execution until the server is actually ready? Atm I’m doing a while loop that checks the IsListening
variable which seems wasteful. Same with the client, except checking if the client IsConnected
.
I would love to be able to do something like:
await WebsocketServer.Start()
await WebsocketClient.Start()
Issue Analytics
- State:
- Created 3 years ago
- Comments:24 (16 by maintainers)
Top Results From Across the Web
Is there any way to wait for AJAX response and halt ...
Here is some code I'd like to execute. I'd like to wait for AJAX response so I can return something from the server....
Read more >Understanding and Handling Connection Lifetime Events ...
When a connection is inactive, periodically the server sends a keepalive packet to the client. As of the date this article is being...
Read more >Let It Crash: Best Practices for Handling Node.js Errors on ...
Let's say we have a server running. It's receiving requests and establishing connections with clients. But what happens if the process crashes?
Read more >Understanding Control Flow with Async and Await in C# | ...
GetResult() on the task, which is a blocking call. Again, this is synchronous; no execution will take place on the current thread until...
Read more >Understanding the Event Loop, Callbacks, Promises, and ...
The task is to get the third function to always delay execution until after the asynchronous action in the second function has completed....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This should do it. I’m going to do some more research into returning the actual Task without blocking should it be awaited.
NuGet: https://www.nuget.org/packages/WatsonWebsocket/2.2.1.3 Commit: https://github.com/jchristn/WatsonWebsocket/commit/f5756d88e796da9b5c87b3240d3b4b71e7c13493
Please close if this works for you, or let me know if any issues remain!
Ex:
We could add a
StartAsync
method to both, would that work? In the server it would return theAcceptConnections
task, and in the client, it would return theConnectAsync
task; both could be awaited.