Reputation: 3684
I'm using socket.io
in total.js and want to use the io
object in a module.
how can i access the io
object in a module? (pass the object or set the global framework
object?)
the initialization code:
require("total.js");
ON("load", function() {
let io = require("socket.io")(this.server);
});
F.http("debug");
Upvotes: 0
Views: 159
Reputation: 748
First you need to disable WebSocket in Total.js framework: https://docs.totaljs.com/latest/en.html#api~FrameworkConfiguration~allow_websocket
Initialization code for Socket.io:
ON('ready', function() {
// "IO" will be a global variable, so you can use it everywhere
global.IO = require('socket.io')(F.server);
});
Upvotes: 1