Lawouach/WebSocket-for-Python — Issue #19: Please store the close code and reason in WebSocketBaseClient
Author: tweber
Created: 2012-01-21 02:21:14+00:00
State: open

When the websocket closes, there is a code and a reason. I can subclass it and override closed() to get these. But I cannot get them if I am handed a stock websocket object, for example when I use WSGI server (with gevent). Therefore, could you please store the code and reason in the websocket? For example,

ws4py/client/__init__.py line 106

def close(self, reason='', code=1000):
if not self.client_terminated:
self.client_terminated = True
self.close_code = code ### added ###
self.close_reason = reason ### added ###
self.write_to_connection(self.stream.close(code=code, reason=reason).single(mask=True))