Question

I am learning HTML5 and doing so by building a simple chatroom using Express, PassportJS, Mongoose/MongoDB, connect-mongoose, NowJS.

Everything works perfectly, except for one big problem: I am having trouble authenticating NowJS.

The usual way of doing this is to read the "this.user.cookie" property server-side and parse the string. However, for some reason, cookies is not being sent back to the server. (details here: NowJS cookie field in this.user is empty) After a lot of googling, I think there are no alternative, secured, way for me to authenticate NowJS connections/clients.

Question

I am thinking of stripping all of NowJS out of my web app, and using socket.io directly. Is socket.io easy with work with? Would I lose key functionality if I switch to socket.io, instead of using NowJS?

Can I use socket.io to:

1) Call server-side functions?

2) Share server-side variables with the client?

Was it helpful?

Solution

Socket.io does not share variables or allow you to call server side functions. It allows you to bind and emit events on the client side and server side.

As for your cookie not being sent, its most likely that its being considered a cors, cross domain request, this can happen if your using a different port for socket.io then the http server that set the cookie.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top