Skip to content
This repository

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

Closed
MightyCodder opened this Issue · 5 comments

4 participants

MightyCodder Steve Wang Zhenghao Qian Eric Zhang
MightyCodder

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

Steve Wang

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.

Zhenghao Qian

@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?

Steve Wang

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.

MightyCodder

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

Eric Zhang

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

Eric Zhang ericz closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.