Can we lookup instances of DOs from one DO's WebSocket message handler?

I’ve been trying to using DOs for websocket handling, I’ve seen that the message handling function is getting called when I send a message from the front end. However, I also saw that there is no context object being passed to that function. How can I lookup other DO instances in the function that handles incoming websocket messages? Thanks in advance
3 Replies
Hello, I’m Allie!
The State and Environment of the DO are only passed into the constructor. It is up to you to store them
Milan
Milan10mo ago
In your constructor you would want to do something like
constructor(state, env) {
this.state = state;
this.env = env
}
constructor(state, env) {
this.state = state;
this.env = env
}
Then in your webSocketMessage() handler you can use this.state, this.env.
98thpixel
98thpixel10mo ago
Thanks a lot!
Want results from more Discord servers?
Add your server