getting proper max userId
This commit is contained in:
@@ -19,7 +19,6 @@ app.get('/', function (req, res) {
|
|||||||
res.sendFile(__dirname + '/index.html');
|
res.sendFile(__dirname + '/index.html');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
function handleDisconnect() {
|
function handleDisconnect() {
|
||||||
con = mysql.createConnection(db_config); // Recreate the connection, since
|
con = mysql.createConnection(db_config); // Recreate the connection, since
|
||||||
// the old one cannot be reused.
|
// the old one cannot be reused.
|
||||||
@@ -42,6 +41,16 @@ function handleDisconnect() {
|
|||||||
}
|
}
|
||||||
handleDisconnect();
|
handleDisconnect();
|
||||||
|
|
||||||
|
app.get('/userid', function (req, res) {
|
||||||
|
var currUserId;
|
||||||
|
con.query('SELECT max(userId) from messages;', function (err, result, fields) {
|
||||||
|
if (err) throw err;
|
||||||
|
currUserId = result + 1;
|
||||||
|
});
|
||||||
|
|
||||||
|
res.json(currUserId);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
io.on('connection', function (socket) {
|
io.on('connection', function (socket) {
|
||||||
console.log('Client connected: ' + socket.id);
|
console.log('Client connected: ' + socket.id);
|
||||||
|
|||||||
Reference in New Issue
Block a user