def on_message(self, websocket, message):
waiter = self._waiter<EOL>self._waiter = None<EOL>encoded = json.loads(message)<EOL>event = encoded.get('<STR_LIT>')<EOL>channel = encoded.get('<STR_LIT>')<EOL>data = json.loads(encoded.get('<STR_LIT:data>'))<EOL>try:<EOL><INDENT>if event == PUSHER_ERROR:<EOL><INDENT>raise PusherError(data['<STR_LIT:message>'], data['<STR_LIT:code>'])<EOL><DEDENT>elif event == PUSHER_CONNECTION:<EOL><INDENT>self.socket_id = data.get('<STR_LIT>')<EOL>self.logger.info('<STR_LIT>',<EOL>self.socket_id)<EOL>waiter.set_result(self.socket_id)<EOL><DEDENT>elif event == PUSHER_SUBSCRIBED:<EOL><INDENT>self.logger.info('<STR_LIT>',<EOL>encoded.get('<STR_LIT>'))<EOL><DEDENT>elif channel:<EOL><INDENT>self[channel]._event(event, data)<EOL><DEDENT><DEDENT>except Exception as exc:<EOL><INDENT>if waiter:<EOL><INDENT>waiter.set_exception(exc)<EOL><DEDENT>else:<EOL><INDENT>self.logger.exception('<STR_LIT>')<EOL><DEDENT><DEDENT>
Handle websocket incoming messages