1

I am creating a TCP based game server for iOS, it involves registration and login. Users will be stored as a collection in MongoDB. when login is done, I generate a unique session id - How ?

I wanted to know what all data remains with node server and what can be stored in db. data like session tokens, or collection of sockets if I am maintaining a persistent connection etc.

2 Answers 2

2

Node.JS does not have any sessions by default. In fact, there is a plug-in for managing sessions with MongoDB.

It's not clear that you really need sessions however. If you're opening a direct socket with socket.io, that is a defacto session.

Sign up to request clarification or add additional context in comments.

1 Comment

I was thinking, in case I go for HTTP based communication, I will need some sort of user tracking, If I am using sockets, then its not a problem at all.
0

Node.js itself does not manage sessions for you. It simply exposes an API to underlying unix facilities for Socket communication. HTTP in it self is a stateless protocol and does not have sessions either. SSH on the other hand is a stateful protocol, but I do not think either one would be good for you.

Creating a uniuqe ID is really simple, all you need to do is hash some data about the user. Their SHA(IP address + time + username). See: http://nodejs.org/api/crypto.html

One approach a lot of applications take is to create their own protocol and send messages using that. You will have to handle a lot of cases with that. And I myself have never dealt with mobile where you have serious connectivity challenges and caching requirements that are not a big problem on desktops.

To solve these problem, founder of Scribd started a company called Parse which should make it much easier for your to do things. Have a look at their website: https://parse.com/.

If you want to do some authentication however, have a look at Everyauth, it provides a lot of that for you. You can find it here: https://github.com/bnoguchi/everyauth/.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.