Stream-notify-room method is not working

Am using websocket to communicate with the Rocket chat server. Am trying to implement the typing event indicator on the UI. For that, am calling “stream-notify-room” method. But it is not working.

  • I have initiated a ‘stream-notify-room’ subscription, when a room is created
    this.$socket.send({ msg: 'sub', id: '42', name: 'stream-notify-room', params: [ this.room + '/typing', false ] })

  • Subscription functionality is working fine. I tested and confirmed by connecting the Rocket chat server.

  • From the UI, On message typing, I have triggered
    this.$socket.send({ msg: 'method', method: 'stream-notify-room', id: '42', params: [ this.room + '/typing', this.$attrs.user.username, true ] })

  • From the UI, On message clear/typing stop, I have triggered
    this.$socket.send({ msg: 'method', method: 'stream-notify-room', id: '42', params: [ this.room + '/typing', this.$attrs.user.username, false ] })

  • On these two above event the socket message shows as
    { "msg": "result", "id": "stream-notify-room-cKe3k3Mkhk7d8i9y2" }

There is no socket message reaching on the other user(on same room) side. Am expecting some message should be reach on the other user socket and display the typing event.

Please let me know what is wrong in my steps.

Hi,

Can you go back a bit and describe what you are trying to achieve? What are you using to communicate?

A bit more background might help.

Hi John,

Thanks for your reply.

I am integrating the rocket chat to our application using the realtime APIs.

Here am trying to notify the users(in the same room) when an user typing the message.

For this purpose, I have triggered, following method on message typing(on text box)

this.$socket.send({ msg: ‘method’, method: ‘stream-notify-room’, id: ‘42’, params: [ this.room + ‘/typing’, this.$attrs.user.username, true ] })

Hi @john.crisp

I hope you got the idea about what am facing. Can you please help me to resolve this.

Thanks

I am having the same problem as this. I am trying to broadcast an event through websocket, so that other users can get notified of an event, but unfortunately only the user who sent the stream-notify-room message is receiving the message.

I tried the exact same steps as this post, but it did not work. The documentation here Notify Room Stream - Rocket.Chat Developer
indicates that other users in the room will be notified of an event. Unfortunately, no other users in the same room is receiving any message.

Hi @skhds

I still have not yet found the solution

I solved my situation by just using the “sendMessage” method instead.
On the params, in addition to “_id”, “rid”, and “msg”, “t” can be inserted and passed around, so I think you can use that to filter the message and treat it as an “event”.

Of course, this does not mean that stream-notify-room shouldn’t work, or at least the documentation should change. There is no indication that you can pass your own “t” in “sendMessage” method, this was rather found by me just experimenting things.