1

I am currently using Rocket.Chat with real time API.

I subscribe to room messages by sending the following message to Rocket.Chat websocket

{
    "msg": "sub",
    "id": "unique-id",
    "name": "stream-room-messages",
    "params":[
        "room-id",
        false
    ]
}

Is it possible to unsubscribe room message or room notifications?

Marc Bouvier
  • 642
  • 1
  • 11
  • 27

1 Answers1

2

I lack the required reputation to comment, so sorry about this.

I've discovered that I get a non-error response when I send the following:

{
  "msg": "unsub",
  "id": this._generateCallID(),
  "name": "stream-room-messages",
  "params":[
     roomID,
     true
  ]
 }

This gives the following response:

{msg: "nosub", id: "ev5553ewl"}

I feel like I may be in the correct ballpark, but with the wrong ID or parameters. I'll keep you updated.

UPDATE: I did some digging and found this in an issue:

{"msg": "unsub", "id": "subscriptionId"}

To unsubscribe from a channel, you simply provide your subscriptionID. The subscription ID being whatever ID you assigned to it when you made the subscription call initially. I can confirm this method is working for my use-case.

Galatoni
  • 68
  • 8
  • Exactly, what I missed there, is that I needed to give back the id I provided during the subscription. Thank you! – Marc Bouvier Apr 12 '18 at 09:54
  • I updated the documentation on Rocket Chat to include this information. – Galatoni Apr 13 '18 at 08:43
  • @Galatoni Is this still working? Because whenever I send the id used to create the subscription, I receive a nosub response... – Cristiano Santos Jul 05 '18 at 13:18
  • @CristianoSantos If you take a look at the documentation, I noted this. https://rocket.chat/docs/developer-guides/realtime-api/subscriptions/ – Galatoni Jul 06 '18 at 14:44
  • @Galatoni I noticed that but it is not working as I reported in here: https://forums.rocket.chat/t/unsubscribe-from-stream-room-messages/1500 – Cristiano Santos Jul 09 '18 at 09:23
  • It might be worth raising an additional bug then. Since the project is still in beta, there are going to be a number of changes that need to take place. If you've got time, it might be worth you making the adjustments yourself. – Galatoni Jul 13 '18 at 10:38