+ def received_message(self, m):
+ with self._closing_lock:
+ if not self._closing:
+ self.on_event(json.loads(str(m)))
+
+ def close(self, code=1000, reason='', timeout=0):
+ """Close event client and optionally wait for it to finish.
+
+ :timeout: is the number of seconds to wait for ws4py to
+ indicate that the connection has closed.
+ """
+ super(EventClient, self).close(code, reason)
+ with self._closing_lock:
+ # make sure we don't process any more messages.
+ self._closing = True
+ # wait for ws4py to tell us the connection is closed.
+ self._closed.wait(timeout=timeout)