Replies: 1 comment
-
Hey @13Aks13
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
What's wrong? Why .emit is not a function?
'use strict'
const Ws = use('Ws')
class SocketHelper {
static sendEvent(channel, message, data, typeEvent = 0) {
const socket = Ws.getChannel(channel).topic(channel)
if (socket) {
/*
EMIT = 0,
BROADCAST = 1,
BROADCASTALL = 2;
*/
if (typeEvent == 1) {
try {
socket.broadcast(message, data)
} catch(error) {
console.error("Socket send error: ", error)
}
} else if (typeEvent == 2) {
try {
socket.broadcastToAll(message, data)
} catch(error) {
console.error("Socket send error: ", error)
}
} else {
try {
socket.emit(message, data)
} catch(error) {
console.error("Socket send error: ", error)
}
}
}
}
}
module.exports = SocketHelper
Beta Was this translation helpful? Give feedback.
All reactions