Created
October 20, 2021 10:41
-
-
Save velotiotech/c214c301df4c6dff0ccf3957c099e8e2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async publishMessage(data) { | |
const subscribers = await this.getSubscribers(); | |
const promises = subscribers.map(async ({ connectionId, subscriptionId }) => { | |
const TopicSubscriber = new Client(connectionId); | |
const res = await TopicSubscriber.sendMessage({ | |
id: subscriptionId, | |
payload: { data }, | |
type: 'data', | |
}); | |
return res; | |
}); | |
return Promise.all(promises); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment