lua-websockets icon indicating copy to clipboard operation
lua-websockets copied to clipboard

Make client socket accessible?

Open saucisson opened this issue 10 years ago • 0 comments

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?

saucisson avatar Sep 23 '15 09:09 saucisson