Is this a safe and good way to use Websockets for push notifications?

The problem remains: Each authenticated restaurant can execute join /restaurant_id to access the room of other restaurants. And executing /join xxx is necessary.

I think so. I think this is it?
actix::Addr<websocket_server::ChatServer>>

I have rewritten the actor to this.

/// Method is called on actor start.
    /// We register ws session with ChatServer
    fn started(&mut self, ctx: &mut Self::Context) {
        // we'll start heartbeat process on session start.
        self.hb(ctx);

        // register self in chat server. `AsyncContext::wait` register
        // future within context, but context waits until this future resolves
        // before processing any other events.
        // HttpContext::state() is instance of WsChatSessionState, state is shared
        // across all routes within application
        let addr = ctx.address();
        self.addr
            .send(websocket_server::Connect {
                addr: addr.recipient(),
            })
            .into_actor(self)
            .then(|res, act, ctx| {
                match res {
                    Ok(res) => {
                        act.id = res;
                        // REWRITTEN
                        act.addr.do_send(websocket_server::Join {
                            id: act.id,
                            name: act.room.clone(),
                        });
                    }
                    // something is wrong with chat server
                    _ => ctx.stop(),
                }
                fut::ready(())
            })
            .wait(ctx);
    }

And removed the /join command. I think each restaurant now automatically gets connected to it's room and the room can't be changed.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.