Arcypojeb commited on
Commit
08daac0
1 Parent(s): 03a6074

Update clientChaindesk.py

Browse files
Files changed (1) hide show
  1. clientChaindesk.py +9 -12
clientChaindesk.py CHANGED
@@ -10,16 +10,16 @@ client_ports = []
10
 
11
  # Define the websocket client class
12
  class WebSocketClient6:
13
- def __init__(self):
14
- # Initialize the uri attribute
15
- self.name = f"Chaindesk client port: {self.clientPort}"
 
16
  self.status = st.sidebar.status(label=self.name, state="complete", expanded=False)
 
17
 
18
  if "client_ports" not in st.session_state:
19
  st.session_state['client_ports'] = ""
20
- if "clientPort" not in st.session_state:
21
- st.session_state.clientPort = ""
22
-
23
  async def askChaindesk(self, question):
24
 
25
  if "agentID" not in st.session_state:
@@ -75,14 +75,11 @@ class WebSocketClient6:
75
  print("Stopping WebSocket client...")
76
 
77
  # Define a coroutine that will connect to the server and exchange messages
78
- async def startClient(self, clientPort):
79
- uri = f'ws://localhost:{clientPort}'
80
- client_ports.append(clientPort)
81
- st.session_state['client_ports'] = client_ports
82
- st.session_state.clientPort = clientPort
83
  status = self.status
84
  # Connect to the server
85
- async with websockets.connect(uri) as websocket:
86
  # Loop forever
87
  while True:
88
  status.update(label=self.name, state="running", expanded=True)
 
10
 
11
  # Define the websocket client class
12
  class WebSocketClient6:
13
+ def __init__(self, clientPort):
14
+ # Initialize the uri attribute
15
+ self.uri = f'ws://localhost:{clientPort}'
16
+ self.name = f"Chaindesk client port: {clientPort}"
17
  self.status = st.sidebar.status(label=self.name, state="complete", expanded=False)
18
+ st.session_state.clientPort = clientPort
19
 
20
  if "client_ports" not in st.session_state:
21
  st.session_state['client_ports'] = ""
22
+
 
 
23
  async def askChaindesk(self, question):
24
 
25
  if "agentID" not in st.session_state:
 
75
  print("Stopping WebSocket client...")
76
 
77
  # Define a coroutine that will connect to the server and exchange messages
78
+ async def startClient(self):
79
+
 
 
 
80
  status = self.status
81
  # Connect to the server
82
+ async with websockets.connect(self.uri) as websocket:
83
  # Loop forever
84
  while True:
85
  status.update(label=self.name, state="running", expanded=True)