Reputation: 2709
I'm making a browser game that utilizes voice communication, to record audio in the browser I'm using wami-recorder which uses flash to send a POST request to the server with the recorded audio, only it doesn't seem to give me any control over the request.
My game server, which is written in node.js/express, needs to be able to identify the client from the audio it's received, as well as pair it with the correct web socket from socket.io
I've considered using the ip address, however it wouldn't work if there were multiple clients with the same address. I've also considered assigning a unique URL to the client (one of the only things wami let's me do) for them to send the audio to, except I wouldn't want that url stolen somehow and for someone else to have the ability to send audio to it
So I'm wondering if there's a way a post request in express.js can consistently identify a client.
Upvotes: 1
Views: 2174
Reputation: 707686
Your usual options are:
If, as you say in your comments, you can't influence the data that is sent with the request, then you would want to set a cookie that identifies the user before the request is sent and the browser will automatically include the cookie with the request and then your server-side code can examine the cookie that comes with the request to see which user it is. This is the usual way that one "logs in" to a web-site and the server then keeps track of which user a given request is from.
Upvotes: 1