How to use the hibernatable websocket API on workers + durable objects?
I'm creating a worker + DO that accept websocket requests. I'm a little bit confused of how do I implement the hibernatable API. Does someone have an example? And also, how do I know that I did it right?
2 Replies
You accept new connections with the
state.acceptWebSocket
function and your durable object interface should implement the handlers - here is an incomplete example:
There is a full example in the
workers-chat-demo
repo https://github.com/cloudflare/workers-chat-demo/blob/hibernation/src/chat.mjsGitHub
workers-chat-demo/src/chat.mjs at hibernation · cloudflare/workers-...
Contribute to cloudflare/workers-chat-demo development by creating an account on GitHub.