I've developed a chat application using socket.io that is working fine Code is like this
var sys = require('sys');
var fs = require('fs');
var io = require('socket.io');
var Server = require('http').createServer(function(req, response){
response.writeHeader(200,{"Content-Type":"text/html"});
var rs = fs.createReadStream(__dirname + '/chat.html')
sys.pump(rs,response);
});
var socket = io.listen(Server);
socket.sockets.on('connection',function(client){
var username;
client.send('Welcome to chat');
client.send('Enter your name');
client.on('message',function(message){
if(!username)
{
username = message;
client.send('Welcome,' +username);
return;
}
client.send(username + ' sent:' +message)
client.broadcast.send(username + ' sent:' +message);
client.on('disconnect',function(){
sys.puts("disconnected");
})
})
})
Server.listen(10038);
Now i want to retrieve chat history between two users and save it into mysql database. How to get userId of two users that should be unique to save it into database. I'm new to node.js technology. Any suggestions would be useful. And what could be the database schema?