HTTP long polling, detecting client disconnect, using warp

I'm using warp for a web server. It's working nicely so far.

Now, I'm thinking about implementing HTTP long polling in warp. It seems fine to put some sort of async delays in the async handler function, to delay the response until some data is available. So I think that should be fine.

But I'm wondering, how can the handler function detect if/when the client closes the connection?

Generally, frameworks like wrap will cancel the handler function when the connection closes. If you need to do any cleanup, then you can use a variable with a custom destructor, since the destructors of local variables will run when an async fn is cancelled.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.