Skip to content

Instantly share code, notes, and snippets.

@DJanoskova
Created September 1, 2019 07:34
Show Gist options
  • Select an option

  • Save DJanoskova/0dc914e107e331d720a12fe8aaa1bdf7 to your computer and use it in GitHub Desktop.

Select an option

Save DJanoskova/0dc914e107e331d720a12fe8aaa1bdf7 to your computer and use it in GitHub Desktop.
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