mirror of
https://github.com/ENSL/ensl_gathers.git
synced 2024-11-22 12:41:11 +00:00
Added usre model and more skeleton
This commit is contained in:
parent
425ce23ce7
commit
92a2d0442b
10 changed files with 81 additions and 32 deletions
|
@ -1,12 +1,11 @@
|
|||
"use strict";
|
||||
|
||||
var fs = require("fs");
|
||||
var path = require("path");
|
||||
var enslClient = require(path.join(__dirname, "../lib/ensl/client"))();
|
||||
var chatController = require(path.join(__dirname, "../lib/chat/controller"));
|
||||
var gatherController = require(path.join(__dirname, "../lib/gather/controller"));
|
||||
var userController = require(path.join(__dirname, "../lib/user/controller"));
|
||||
var winston = require("winston");
|
||||
var User = require("../lib/user/user");
|
||||
var enslClient = require("../lib/ensl/client")();
|
||||
var chatController = require("../lib/chat/controller");
|
||||
var gatherController = require("../lib/gather/controller");
|
||||
var userController = require("../lib/user/controller");
|
||||
|
||||
module.exports = function (io) {
|
||||
var id = 2131;
|
||||
|
@ -22,7 +21,7 @@ module.exports = function (io) {
|
|||
winston.error(error);
|
||||
return next(error)
|
||||
};
|
||||
socket._user = body;
|
||||
socket._user = new User(body);
|
||||
next();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -10,10 +10,7 @@ function Message (o) {
|
|||
|
||||
Message.prototype.toJson = function () {
|
||||
return {
|
||||
author: {
|
||||
username: this.author.username,
|
||||
avatar: this.author.avatar
|
||||
},
|
||||
author: this.author,
|
||||
content: this.content,
|
||||
createdAt: this.createdAt
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ function EnslClient (options) {
|
|||
return new EnslClient(options);
|
||||
}
|
||||
|
||||
this.baseUrl = (env === "production") ? "http://www.ensl.org/" : "http://staging.ensl.org";
|
||||
this.baseUrl = (env === "production") ? "http://www.ensl.org" : "http://staging.ensl.org";
|
||||
}
|
||||
|
||||
EnslClient.prototype.getUserById = function (options, callback) {
|
||||
|
|
|
@ -4,12 +4,32 @@
|
|||
* Gather Controller
|
||||
*
|
||||
* Server API
|
||||
* gather:refresh - Refreshes active gather
|
||||
*
|
||||
* Client API
|
||||
* gather:join - Assigns user to gather
|
||||
* gather:vote - Assigns vote to map, captain or server
|
||||
*
|
||||
*/
|
||||
|
||||
var Gather = require("./gather");
|
||||
var latestGather = new Gather();
|
||||
|
||||
module.exports = function (namespace) {
|
||||
|
||||
var refreshGather = function () {
|
||||
namespace.emit("gather:refresh", {
|
||||
gather: gather
|
||||
});
|
||||
};
|
||||
|
||||
namespace.on("connection", function (socket) {
|
||||
|
||||
socket.on("gather:join", function (data) {
|
||||
|
||||
});
|
||||
|
||||
socket.on("gather:vote", function (data) {
|
||||
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
@ -19,8 +19,22 @@ function Gather () {
|
|||
}
|
||||
|
||||
this.gatherers = [];
|
||||
this.marines = [];
|
||||
this.aliens = [];
|
||||
}
|
||||
|
||||
Gather.prototype.addGatherer = function (user) {
|
||||
|
||||
};
|
||||
|
||||
Gather.prototype.removeGatherer = function (user) {
|
||||
|
||||
};
|
||||
|
||||
Gather.prototype.moveToMarine = function (user) {
|
||||
|
||||
};
|
||||
|
||||
Gather.prototype.moveToAlien = function (user) {
|
||||
|
||||
};
|
||||
|
||||
module.exports = Gather;
|
|
@ -10,8 +10,13 @@
|
|||
*
|
||||
*/
|
||||
|
||||
function Gatherer () {
|
||||
var User = require("../user/user");
|
||||
|
||||
function Gatherer (user) {
|
||||
this.votes = {};
|
||||
this.id = user.id;
|
||||
this.captain = false;
|
||||
this.team = "lobby";
|
||||
}
|
||||
|
||||
module.exports = Gatherer;
|
|
@ -165,10 +165,6 @@ var ChatMessage = React.createClass({
|
|||
timeAgo: $.timeago(this.props.createdAt)
|
||||
}
|
||||
},
|
||||
imageUrl: function () {
|
||||
var BASE_URL = "http://www.ensl.org/"
|
||||
return BASE_URL + this.props.avatar;
|
||||
},
|
||||
refreshTime: function () {
|
||||
var self = this;
|
||||
self.setState({
|
||||
|
@ -180,7 +176,7 @@ var ChatMessage = React.createClass({
|
|||
<li className="left clearfix">
|
||||
<span className="chat-img pull-left">
|
||||
<img
|
||||
src={this.imageUrl()}
|
||||
src={this.props.avatar}
|
||||
alt="User Avatar"
|
||||
height="40"
|
||||
width="40"
|
||||
|
|
|
@ -13,11 +13,10 @@
|
|||
*
|
||||
*/
|
||||
|
||||
var fs = require("fs");
|
||||
var path = require("path");
|
||||
var enslClient = require(path.join(__dirname, "../ensl/client"))();
|
||||
var winston = require("winston");
|
||||
var userCache = {};
|
||||
var User = require("./user");
|
||||
var winston = require("winston");
|
||||
var enslClient = require("../ensl/client")();
|
||||
|
||||
module.exports = function (namespace) {
|
||||
var refreshUsers = function (socket) {
|
||||
|
@ -61,7 +60,7 @@ module.exports = function (namespace) {
|
|||
winston.error("ENSL API status:", response.statusCode);
|
||||
return;
|
||||
}
|
||||
socket._user = body;
|
||||
socket._user = new User(body);
|
||||
refreshUsers();
|
||||
});
|
||||
});
|
||||
|
|
23
lib/user/user.js
Normal file
23
lib/user/user.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
"use strict";
|
||||
|
||||
/*
|
||||
* Implements User Model
|
||||
*
|
||||
*/
|
||||
|
||||
var client = require("../ensl/client")();
|
||||
|
||||
function User (user) {
|
||||
this.id = user['id'];
|
||||
this.username = user['username'];
|
||||
this.country = user['country'];
|
||||
this.time_zone = user['time_zone'];
|
||||
this.avatar = client.baseUrl + user['avatar'];
|
||||
this.admin = user['admin'];
|
||||
this.steam = {
|
||||
url: user['steam']['url'],
|
||||
nickname: user['steam']['nickname']
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = User;
|
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue