lipp / lua-websockets

Websockets for Lua.
http://lipp.github.com/lua-websockets/
MIT License
396 stars 113 forks source link

Make client socket accessible? #83

Open saucisson opened 8 years ago

saucisson commented 8 years ago

In an application using websocket.server.copas, i need to access some information from the socket: IP address and port. They can be obtained using luasocket's getpeername (). This method is hidden by copas (but can be worked around using sock.socket).

A very simple hack is to add a field containing the socket inside the ws object passed to the handler, as in this commit: d6c32fbdd51dd16f955392ca6575f42f4a838f45. But you may also want a more general solution available also in websocket.server.ev and in clients.

Maybe i just missed an already existing solution?