Skip to content

Commit bfb3ce1

Browse files
authored
Update example for WebSocket hibernation (#24286)
1 parent cee9f39 commit bfb3ce1

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/content/docs/durable-objects/examples/websocket-hibernation-server.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,15 @@ export class WebSocketHibernationServer extends DurableObject {
135135
ws.send(`[Durable Object] message: ${message}, from: ${session.id}. Total connections: ${this.sessions.size}`);
136136

137137
// Send a message to all WebSocket connections, loop over all the connected WebSockets.
138-
this.sessions.forEach((attachment, session) => {
139-
session.send(`[Durable Object] message: ${message}, from: ${attachment.id}. Total connections: ${this.sessions.size}`);
138+
this.sessions.forEach((attachment, connectedWs) => {
139+
connectedWs.send(`[Durable Object] message: ${message}, from: ${session.id}. Total connections: ${this.sessions.size}`);
140140
});
141141

142142
// Send a message to all WebSocket connections except the connection (ws),
143143
// loop over all the connected WebSockets and filter out the connection (ws).
144-
this.sessions.forEach((attachment, session) => {
145-
if (session !== ws) {
146-
session.send(`[Durable Object] message: ${message}, from: ${attachment.id}. Total connections: ${this.sessions.size}`);
144+
this.sessions.forEach((attachment, connectedWs) => {
145+
if (connectedWs !== ws) {
146+
connectedWs.send(`[Durable Object] message: ${message}, from: ${session.id}. Total connections: ${this.sessions.size}`);
147147
}
148148
});
149149
}

0 commit comments

Comments
 (0)