Node.js sample application with Socket.IO
修訂. | 51274ace76f331f34e729b043f5ebeaaea4a2ccd |
---|---|
大小 | 828 bytes |
時間 | 2012-10-29 01:06:50 |
作者 | hylom |
Log Message | implement all features
|
/*
* GET home page.
*/
var crypto = require('crypto');
exports.index = function(req, res){
res.render('index', { title: 'minichat' });
};
exports.room = function(req, res){
var roomName = req.body.roomName || '';
var yourName = req.body.yourName || '';
var password = req.body.password || '';
var mode = req.body.mode;
if (mode === undefined) {
res.send(500);
return;
};
var hashedPassword = '';
var shasum = crypto.createHash('sha512');
if (password !== '') {
shasum.update('initialhash');
shasum.update(password);
hashedPassword = shasum.digest('hex');
}
var params = {
title: 'チャットルーム:' + roomName,
room: {
name: roomName,
password: hashedPassword
},
user: {name: yourName},
mode: mode
};
res.render('room', params);
};