added login , update scan, added user
This commit is contained in:
29
socket.js
Executable file
29
socket.js
Executable file
@ -0,0 +1,29 @@
|
||||
const socketio = require('socket.io');
|
||||
const socketio_client = require('socket.io-client');
|
||||
const dotenv = require('dotenv');
|
||||
|
||||
dotenv.config();
|
||||
|
||||
const socket_client = socketio_client("http://localhost:"+process.env.PORT);
|
||||
|
||||
let io;
|
||||
|
||||
function init(server) {
|
||||
io = socketio(server);
|
||||
return io;
|
||||
}
|
||||
|
||||
function getIO() {
|
||||
if (!io) {
|
||||
throw new Error('Socket.io not initialized');
|
||||
}
|
||||
return io;
|
||||
}
|
||||
|
||||
|
||||
|
||||
module.exports = {
|
||||
init,
|
||||
getIO,
|
||||
socket_client
|
||||
};
|
Reference in New Issue
Block a user