MCPcopy
hub / github.com/Sathvik-Rao/ClipCascade / STOMPManager

Class STOMPManager

ClipCascade_Desktop/src/stomp_ws/stomp_manager.py:22–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20
21
22class STOMPManager(WSInterface):
23 def __init__(self, config: Config, is_login_phase=True):
24 self.config = config
25 self.clipboard_manager = ClipboardManager(self.config)
26 self.cipher_manager = CipherManager(self.config)
27 self.notification_manager = NotificationManager(self.config)
28 self.sys_tray: TaskbarPanel = None
29 self.first_conn_lost = True
30 self.is_login_phase = is_login_phase
31 self.client = None
32 self.is_connected = False
33 self.disconnected = False
34 self.is_auto_reconnecting = False
35
36 def set_tray_ref(self, sys_tray: TaskbarPanel):
37 """
38 Sets the system tray reference.
39 """
40 self.sys_tray = sys_tray
41 self.clipboard_manager.set_tray_ref(sys_tray)
42
43 def get_total_timeout(self):
44 """
45 Returns the total timeout value in milliseconds."""
46 return (RECONNECT_WS_TIMER * 1000) + WEBSOCKET_TIMEOUT
47
48 def get_stats(self):
49 return None
50
51 def connect(self) -> tuple[bool, str]:
52 try:
53 if self.is_connected:
54 return True, ""
55 self.client = Client(
56 self.config.data["websocket_url"],
57 headers={
58 "Cookie": RequestManager.format_cookie(
59 self.config.data["cookie"]
60 )
61 },
62 on_close_callback=self._on_close,
63 sslopt=websocket_sslopt_for_config(self.config),
64 )
65 self.client.connect(
66 timeout=WEBSOCKET_TIMEOUT,
67 connectCallback=lambda _: self.client.subscribe( # receive event
68 destination=SUBSCRIPTION_DESTINATION,
69 callback=self._receive,
70 ),
71 )
72 if self.disconnected:
73 self.disconnect()
74 return False, "Websocket disconnected"
75
76 # logging.info("Websocket connected")
77 self.is_connected = True
78 self.is_auto_reconnecting = False
79 if not self.first_conn_lost:

Callers 1

__init__Method · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected