mirror of
https://github.com/ENSL/ensl_gathers.git
synced 2025-02-21 11:11:23 +00:00
Change terminology to users
This commit is contained in:
parent
acf3c226b3
commit
01a4960827
3 changed files with 40 additions and 42 deletions
|
@ -6,14 +6,12 @@ var enslClient = require(path.join(__dirname, "../lib/ensl/client"))();
|
|||
var chatController = require(path.join(__dirname, "../lib/chat/controller"));
|
||||
var winston = require("winston");
|
||||
|
||||
var gathererCache = {};
|
||||
var userCache = {};
|
||||
|
||||
module.exports = function (io) {
|
||||
var root = io.of("/");
|
||||
var authorised = io.of("/authorised");
|
||||
|
||||
|
||||
|
||||
var id = 2131;
|
||||
|
||||
// Authorisation
|
||||
|
@ -30,7 +28,7 @@ module.exports = function (io) {
|
|||
});
|
||||
});
|
||||
|
||||
var refreshGatherers = function (socket) {
|
||||
var refreshUsers = function (socket) {
|
||||
var receiver = (socket !== undefined) ? socket : root;
|
||||
|
||||
var newCache = {};
|
||||
|
@ -38,19 +36,19 @@ module.exports = function (io) {
|
|||
var user = socket._user;
|
||||
newCache[user.id] = user;
|
||||
});
|
||||
gathererCache = newCache;
|
||||
userCache = newCache;
|
||||
|
||||
var gatherers = [];
|
||||
var users = [];
|
||||
|
||||
for (var id in gathererCache) {
|
||||
if (gathererCache.hasOwnProperty(id)) {
|
||||
gatherers.push(gathererCache[id]);
|
||||
for (var id in userCache) {
|
||||
if (userCache.hasOwnProperty(id)) {
|
||||
users.push(userCache[id]);
|
||||
}
|
||||
}
|
||||
|
||||
receiver.emit('gatherCount', {
|
||||
receiver.emit('userCount', {
|
||||
count: root.sockets.length,
|
||||
gatherers: gatherers
|
||||
users: users
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -58,9 +56,9 @@ module.exports = function (io) {
|
|||
chatController(root);
|
||||
|
||||
io.on('connection', function (socket) {
|
||||
refreshGatherers();
|
||||
refreshUsers();
|
||||
|
||||
socket.on('refreshGathers', refreshGatherers.bind(null, socket));
|
||||
socket.on('refreshUsers', refreshUsers.bind(null, socket));
|
||||
|
||||
socket.on("authorize:id", function (data) {
|
||||
var id = parseInt(data.id, 10);
|
||||
|
@ -72,12 +70,12 @@ module.exports = function (io) {
|
|||
return winston.error(error);
|
||||
}
|
||||
socket._user = body;
|
||||
refreshGatherers();
|
||||
refreshUsers();
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('disconnect', function (socket) {
|
||||
refreshGatherers();
|
||||
refreshUsers();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
@ -2,12 +2,12 @@ $(function () {
|
|||
|
||||
"use strict";
|
||||
|
||||
var GatherCounter = React.createClass({
|
||||
var UserCounter = React.createClass({
|
||||
render: function () {
|
||||
return (
|
||||
<li>
|
||||
<a href="#">
|
||||
<i className="fa fa-users fa-fw"></i> Gatherers
|
||||
<i className="fa fa-users fa-fw"></i> Online
|
||||
<span className="badge add-left"> {this.props.count} </span>
|
||||
</a>
|
||||
</li>
|
||||
|
@ -53,30 +53,30 @@ var UserLogin = React.createClass({
|
|||
}
|
||||
})
|
||||
|
||||
var Gatherer = React.createClass({
|
||||
var User = React.createClass({
|
||||
render: function () {
|
||||
return (
|
||||
<li>
|
||||
<a href="#">{this.props.gatherer.username}</a>
|
||||
<a href="#">{this.props.user.username}</a>
|
||||
</li>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
var GathererMenu = React.createClass({
|
||||
var UserMenu = React.createClass({
|
||||
componentDidMount: function () {
|
||||
socket.on('gatherCount', this.updateGatherers);
|
||||
socket.on('userCount', this.updateUsers);
|
||||
},
|
||||
updateGatherers: function (data) {
|
||||
updateUsers: function (data) {
|
||||
this.setProps({
|
||||
count: data.count,
|
||||
gatherers: data.gatherers
|
||||
users: data.users
|
||||
});
|
||||
},
|
||||
render: function () {
|
||||
var gatherers = this.props.gatherers.map(function (gatherer) {
|
||||
var users = this.props.users.map(function (user) {
|
||||
return (
|
||||
<Gatherer gatherer={gatherer} />
|
||||
<User user={user} />
|
||||
);
|
||||
});
|
||||
return (
|
||||
|
@ -84,8 +84,8 @@ var GathererMenu = React.createClass({
|
|||
<li>
|
||||
<UserLogin />
|
||||
</li>
|
||||
<GatherCounter {...this.props} />
|
||||
{gatherers}
|
||||
<UserCounter {...this.props} />
|
||||
{users}
|
||||
</ul>
|
||||
);
|
||||
}
|
||||
|
@ -251,7 +251,7 @@ function initialiseComponents () {
|
|||
console.log("Disconnected")
|
||||
});
|
||||
|
||||
React.render(<GathererMenu count={0} gatherers={[]} />, document.getElementById('side-menu'));
|
||||
React.render(<UserMenu count={0} users={[]} />, document.getElementById('side-menu'));
|
||||
React.render(<Chatroom history={[]}/>, document.getElementById('chatroom'));
|
||||
};
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue