-
Notifications
You must be signed in to change notification settings - Fork 4
Using Socket.io
Alexander edited this page Jul 29, 2019
·
1 revision
How to use Socket.io Client in Drupi.
Basic methods:
//Open new Socket
var sock = socket.newConnection("url")
//Emit to socket:
sock.emit("index", "args");
//Listen for emits:
socket.on("index", function("args"){
});
//Connect to socket:
sock.connect();
Full example:
var sock = socket.newConnection("http://localhost:8083")
sock.on("ree", function(re){
logger.info(re[0])
})
manager.createCommand("emit", "emit to socket", "emitCommand");
function emitCommand(sender, args){
if(args[0]){
sock.emit("test", args[0])
sender.sendMessage("Done..");
}
}
sock.connect();