-
Notifications
You must be signed in to change notification settings - Fork 214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use this.ctx.storage
to store session data
#82
Conversation
(instead of connection.state)
4ca728c
to
5b5aef7
Compare
07ccec2
to
d303f0c
Compare
Hope you don't mind — I threw up a commit that I think gets this into working order the way we want. Now that room state is derived from the session storage we can't rely on The other change I made was that I noticed we were calling this.ctx.storage.put(`session-${connection.id}`, JSON.stringify(user)) I went ahead and removed this since DO storage accepts structured clone compatible data types. I deployed this change, joined a meeting in a couple tabs, and did another deployment, and the desired outcome was achieved: the room state did not change while the durable object restarted and the WebSocket connections reconnected successfully. |
@@ -172,14 +169,13 @@ export class ChatRoom extends Server<Env> { | |||
const otherUser = await this.ctx.storage.get<User>( | |||
`session-${data.id}` | |||
) | |||
this.ctx.storage.put(`session-${data.id}`, { | |||
await this.ctx.storage.put(`session-${data.id}`, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch, I really need to land the new linting rules, I'll do so next week
looks good! feel free to review and land this whenever you feel like it |
this.ctx.storage
to store session datathis.ctx.storage
to store session data
d303f0c
to
70efa1d
Compare
70efa1d
to
b202213
Compare
(instead of connection.state)