pokemon-showdown/dev-tools/users-utils.js
Ivo Julca cd36fbfde2 Gulpfile: add more JSCS rules
- Disallow spaces between function names and round brackets.
- Disallow spaces inside array/object literal brackets.
- Disallow spaces before semicolons.
- Disallow yoda conditions for equality.
2015-07-28 19:38:53 -05:00

24 lines
715 B
JavaScript

function createConnection(ip, workerid, socketid) {
if (!workerid || !socketid) {
workerid = Object.keys(Sockets.workers)[0];
socketid = 1;
while (Users.connections[workerid + '-' + socketid]) {
socketid++;
}
}
var connectionid = workerid + '-' + socketid;
var connection = Users.connections[connectionid] = new Users.Connection(connectionid, Sockets.workers[workerid], socketid, null, ip || '127.0.0.1');
return connection;
}
function createUser(connection) {
if (!connection) connection = createConnection();
var user = new Users.User(connection);
connection.user = user;
user.joinRoom('global', connection);
return user;
}
exports.Connection = createConnection;
exports.User = createUser;