Skip to content

Subscribing to multiple topics results in last callback being called #36

@clarkbynum

Description

@clarkbynum

This is because we reassign messaging.messageCallback every time subscribe is called - https://github.com/ClearBlade/JavaScript-API/blob/master/index.js#L2174

Currently the only way to subscribe to multiple topics is by creating a new messaging client for each topic which results in a new websocket connection. It would be nice if we could reuse the same connection.

Proposed fix: keep a reference to the callbacks in a dictionary where the keys are the topic name and then in onMessageArrived (https://github.com/ClearBlade/JavaScript-API/blob/master/index.js#L2088) we would find which callback we need to call.

Side note: we should also understand the performance tradeoffs of using multiple connections for multiple topics vs. one connection for multiple topics.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions