Register callback for a data channel message.
When the data channel receives a valid JSON string, the
class_nameproperty of the JSON object will be examined and the corresponding callback function will be called. The string return value of the callback will be sent back as a reply, if it is not empty.
Ordering between the message and the reply is not guaranteed, since some messages may take longer to process than others. If ordering is important, use a unique message id for every message and include it in the reply.
# Register callback in Python import open3d as o3d o3d.visualization.webrtc_server.enable_webrtc() def send_ack(data): print(data) return "Received WebRTC data channel message with data: " + data o3d.visualization.webrtc_server.register_data_channel_message_callback( "webapp/input", send_ack)
class_name (str) – The value of of the
class_nameproperty of the JSON object.
callback (Callable[[str], str]) – The callback function that will be called when a JSON object with the matching
class_nameis received via the data channel. The function should accept a
stringargument (corresponding to the event data, such as form data or updated value of a slider) and return a