I’m using AutobahnJS to visualize measurement data received via different WAMP events. Works pretty good. Sometimes I need to unsubscribe from a topic and instead subscribe to a different topic. For this exercise lets assume I’m switching between the reception of data from two sensors. Furthermore lets assume I have a global variable called sensorSubscription that stores my subscription and is initialized with NULL.
The subscription process works and sensorSubscription becomes a Subscription object. So far so good. The problem now is that after wampSession.unsubscribe(sensorSubscription) I thought that my subscription object is being destroyed and my sensorSubscription variable is becoming NULL again. After I realized that sensorSubscription still references the same Subscription object I checked if it might contain some property that I can use to verify if my subscription is still valid or not (before overwriting it with a new subscription). I found the active property but realized that it’s always set to FALSE. No matter if I unsubscribed or not.
I guess my question is simply how to correctly unsubscribe in AutobahnJS so that I can reuse my sensorSubscription variable for a new subscription.
Many thanks for your help,