You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nodebb/src/websockets.js

51 lines
1.0 KiB
JavaScript

var SocketIO = require('socket.io').listen(global.server);
(function(io) {
var modules = null;
global.io = io;
module.exports.init = function() {
modules = global.modules;
}
io.sockets.on('connection', function(socket) {
global.socket = socket;
if (DEVELOPMENT === true) {
// refreshing templates
modules.templates.init();
}
socket.emit('event:connect', {status: 1});
// BEGIN: API calls (todo: organize)
socket.on('user.create', function(data) {
modules.user.create(data.username, data.password, data.email);
});
socket.on('user.exists', function(data) {
modules.user.exists(data.username);
});
socket.on('user.count', function(data) {
modules.user.count(data);
});
socket.on('user.latest', function(data) {
modules.user.latest(data);
});
socket.on('user.login', function(data) {
modules.user.login(data);
});
socket.on('user.email.exists', function(data) {
modules.user.email.exists(data.email);
});
});
}(SocketIO));