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.
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'sgetpeername ()
. This method is hidden bycopas
(but can be worked around usingsock.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 inwebsocket.server.ev
and in clients.Maybe i just missed an already existing solution?