Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ description: Build a WebSocket server using WebSocket Hibernation on Durable
Objects and Workers.
---

import { TabItem, Tabs, WranglerConfig } from "~/components";
import { TypeScriptExample, WranglerConfig } from "~/components";

This example is similar to the [Build a WebSocket server](/durable-objects/examples/websocket-server/) example, but uses the WebSocket Hibernation API. The WebSocket Hibernation API should be preferred for WebSocket server applications built on Durable Objects, since it significantly decreases duration charge, and provides additional features that pair well with WebSocket applications. For more information, refer to [Use Durable Objects with WebSockets](/durable-objects/best-practices/websockets/).
Expand Down Expand Up @@ -52,6 +53,8 @@ export default {

return stub.fetch(request);
}
return stub.fetch(request);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix this. It seems to worsen a subsequent diff by a lot.

}

return new Response(
`Supported endpoints:
Expand Down Expand Up @@ -126,6 +129,11 @@ export class WebSocketHibernationServer extends DurableObject {
webSocket: client,
});
}
return new Response(null, {
status: 101,
webSocket: client,
});
}

async webSocketMessage(ws: WebSocket, message: ArrayBuffer | string) {
// Get the session associated with the WebSocket connection.
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.