Flotype / now

NowJS makes it easy to build real-time web apps using JavaScript
http://www.nowjs.com
MIT License
1.91k stars 175 forks source link

Is there a way to retrieve the clients IP address? #168

Closed ghost closed 12 years ago

ghost commented 12 years ago

Before each transaction, is it possible to have a function fired as an event?

Also, I am looking for a way to get the client's ip address in nowJS. Is this information integrated in this module or I have to access it with socket.io?

Thanks,

MightyCodder

steveWang commented 12 years ago

By transaction, what do you mean? Certainly you have nowjs events as well as group events. So, uh, probably. There are also the undocumented events multicall and closurecall. I can't see it being too difficult to add yet another event for function calls, but I'm not sure it'd be particularly useful.

And for the second: I believe that it's user.socket.handshake.address, where user is a user object.

Peterfly commented 12 years ago

@steveWang hey Steve, i'm currently doing something about the cookies. you know that this.user.cookie = socket.handshake.headers.cookie but the cookie stores nothing, it's {}. what's that for or what's under socket.handshake?

steveWang commented 12 years ago

It's not actually synchronized with the client's cookie; it only stores data that was in the user's cookie when the user connected. So if you were to store something in document.cookie on the user side, it'd show up the next time the user connected. This is mostly used for persistence and whatnot.

Also, socket.handshake just contains the details of the handshake when the user connects. Not much to it. It's entirely done on Socket.IO's end, if you want to look more into it.

ghost commented 12 years ago

By transactions I was meaning every time data is sent or received. Thanks for your answer.

ericz commented 12 years ago

Closing. Feel free to reopen if there are additional issues.