Created
September 1, 2019 07:34
-
-
Save DJanoskova/0dc914e107e331d720a12fe8aaa1bdf7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| const Ws = use('Ws') | |
| function broadcast (id, type, data) { | |
| const channel = Ws.getChannel('room:*') | |
| if (!channel) return | |
| const topic = channel.topic(`room:${id}`) | |
| if (!topic) { | |
| console.error('Has no topic') | |
| return | |
| } | |
| // emit, broadcast, broadcastToAll | |
| topic.broadcastToAll(`message`, { | |
| type, | |
| data | |
| }); | |
| } | |
| module.exports = { | |
| broadcast | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment