def receive(self, text_data=None, bytes_data=None, **kwargs): Presence.objects.touch(self.channel_name) try: printer = Printer.with_archived.get(id=self.current_printer().id) if text_data: data = json.loads(text_data) else: data = bson.loads(bytes_data) if 'janus' in data: channels.send_janus_to_web(self.current_printer().id, data.get('janus')) elif 'http.tunnel' in data: redis.octoprinttunnel_http_response_set( data['http.tunnel']['ref'], data['http.tunnel'] ) elif 'ws.tunnel' in data: channels.send_message_to_octoprinttunnel( channels.octoprinttunnel_group_name(self.current_printer().id), data['ws.tunnel'], ) elif 'passthru' in data: channels.send_message_to_web(printer.id, data) else: process_octoprint_status(printer, data) except ObjectDoesNotExist: import traceback; traceback.print_exc() self.close() except: # sentry doesn't automatically capture consumer errors import traceback; traceback.print_exc() self.close() sentryClient.captureException()
def receive(self, text_data=None, bytes_data=None, **kwargs): if time.time() - self.last_touch > TOUCH_MIN_SECS: self.last_touch = time.time() Presence.objects.touch(self.channel_name) try: if text_data: data = json.loads(text_data) else: data = bson.loads(bytes_data) if 'janus' in data: channels.send_janus_to_web( self.printer.id, data.get('janus')) elif 'http.tunnel' in data: cache.octoprinttunnel_http_response_set( data['http.tunnel']['ref'], data['http.tunnel'] ) elif 'http.tunnelv2' in data: cache.octoprinttunnel_http_response_set( data['http.tunnelv2']['ref'], data['http.tunnelv2'] ) elif 'ws.tunnel' in data: channels.send_message_to_octoprinttunnel( channels.octoprinttunnel_group_name(self.printer.id), data['ws.tunnel'], ) elif 'passthru' in data: channels.send_message_to_web(self.printer.id, data) else: printer = Printer.with_archived.annotate( ext_id=F('current_print__ext_id') ).get(id=self.printer.id) ex: Optional[Exception] = None data['_now'] = now() try: process_octoprint_status(printer, data) self.anomaly_tracker.track(printer, data) except ResurrectionError as ex: self.anomaly_tracker.track(printer, data, ex) except ObjectDoesNotExist: import traceback traceback.print_exc() self.close() except Exception: # sentry doesn't automatically capture consumer errors import traceback traceback.print_exc() sentryClient.captureException()
def receive_json(self, data, **kwargs): Presence.objects.touch(self.channel_name) try: printer = Printer.objects.get(id=self.current_printer().id) if 'janus' in data: channels.send_janus_to_web(self.current_printer().id, data.get('janus')) elif 'passthru' in data: channels.send_message_to_web(printer.id, data) else: process_octoprint_status(printer, data) except ObjectDoesNotExist: import traceback; traceback.print_exc() self.close() except: # sentry doesn't automatically capture consumer errors import traceback; traceback.print_exc() self.close() sentryClient.captureException()