I am making a game for TWO players with node.js, socket.io and express.
In order to avoid effect from the third person that come to play, i want to generate specific URL for the two who are ready to play.
So my question is, how to change the URL when two people have come?
I am now testing it in local. In the server side, i have server listen to a port.
var express = require('express');
var SocketIO = require('socket.io');
var http = require('http');
var path = require('path');
var app = express({
views: path.join(__dirname, 'views')
});
app.use('/assert', express.static(path.join(__dirname, 'assert')));
app.engine('html', require('ejs').renderFile);
app.get('/', function (req, res) {
res.render('home.html', {layout: false});
});
var server = http.createServer(app);
var sio = SocketIO.listen(server);
server.listen(8080);
function(...){...}
In the client side, i have socket connected to somewhere.
var socket = io.connect('http://' + location.host);
var ....
i guess what i need to do is to provide a button when i detect that two clients come in. When they clicked it, it direct them to a generated new URL.
So there is an old URL and many new ones...
Then how can i set different URLs in both server and client??
Any help is appreciated^ ^