Skip to content

Commit

Permalink
Added lastLogin
Browse files Browse the repository at this point in the history
  • Loading branch information
JonnyD committed Jan 16, 2014
1 parent 8f14fa1 commit d24614b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ CREATE TABLE IF NOT EXISTS `event_type` (
CREATE TABLE IF NOT EXISTS `player` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(32) NOT NULL,
`online` tinyint(1) NOT NULL DEFAULT '0',
`last_login` timestamp,
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `username` (`username`)
Expand Down
5 changes: 3 additions & 2 deletions skynet.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ function bindEvents(bot) {
function(playerId, eventId, callback) {
addSession(player.username, playerId, eventId, function(sessionId) {
console.log("[" + timestamp + "] Started session: " + sessionId + " for " + player.username + " (" + playerId +")");
updateLastLogin(playerId, timestamp);
callback(null, playerId, sessionId);
});
}
Expand Down Expand Up @@ -330,8 +331,8 @@ function createPlayer(username, timestamp, callback) {
});
}

function updatenOnlineStatus(playerId, isOnline) {
connection.query("UPDATE player SET online = " + isOnline + " WHERE id = " + playerId);
function updateLastLogin(playerId, timestamp) {
connection.query("UPDATE player SET last_login = " + timestamp + " WHERE id = " + playerId);
}

function getTimestamp() {
Expand Down

0 comments on commit d24614b

Please sign in to comment.