def on_data(self, ws, message, message_type, fin):
        """
        Callback executed when message is received from the server.

        :param ws: Websocket client
        :param message: utf-8 string which we get from the server.
        :param message_type: Message type which is either ABNF.OPCODE_TEXT or ABNF.OPCODE_BINARY
        :param fin: continue flag. If 0, the data continues.
        """
        try:
            if message_type == websocket.ABNF.OPCODE_TEXT:
                json_object = json.loads(message)
                if 'binary_streams' in json_object:
                    self.callback.on_content_type(json_object['binary_streams'][0]['content_type'])
                elif 'error' in json_object:
                    self.on_error(ws, json_object.get('error'))
                    return
                else:
                    self.callback.on_timing_information(json_object)
        except Exception:
            self.on_error(ws, 'Unable to parse received message.')

        if message_type == websocket.ABNF.OPCODE_BINARY:
            self.callback.on_audio_stream(message)

        self.callback.on_data(message)
Callback executed when message is received from the server.

        :param ws: Websocket client
        :param message: utf-8 string which we get from the server.
        :param message_type: Message type which is either ABNF.OPCODE_TEXT or ABNF.OPCODE_BINARY
        :param fin: continue flag. If 0, the data continues.