Commit a2fbd1d1 authored by Jiahang Chen's avatar Jiahang Chen
Browse files

delete websocket

parent 447146c5
Pipeline #349040 passed with stage
in 13 seconds
import ast
import threading
import websocket
import json
import uuid
from s3i import IdentityProvider, TokenType, GetValueReply, Directory, Repository
......@@ -189,51 +188,6 @@ def __connect_with_repo(self):
)
self.repo = Repository(s3i_repo_url=BaseVariable.REPO_URL, token=self.__access_token)
self._ws = websocket.WebSocketApp(
BaseVariable.REPO_WWS_URL,
header={"Authorization: Bearer {}".format(self.__access_token)},
on_message=self.__on_new_websocket_message,
on_error=self.__on_new_websocket_error,
on_open=self.__on_websocket_connection_opened,
on_close=self.__on_websocket_connection_closed,
)
threading.Thread(target=self._ws.run_forever).start()
@staticmethod
def __on_new_websocket_message(ws, msg):
pass
@staticmethod
def __on_new_websocket_error(ws, error):
print(BColors.OKBLUE + "[S³I][Repo]" + BColors.ENDC + " : Websocekt error")
def __on_websocket_connection_opened(self):
self.__ws_connected = True
self._ws.send("START-SEND-MESSAGES")
print(
BColors.OKBLUE
+ "[S³I][Repo]"
+ BColors.ENDC
+ ": Websocket connection built"
)
def __on_websocket_connection_closed(self):
self.__ws_connected = False
print(
BColors.OKBLUE
+ "[S³I][Repo]"
+ BColors.ENDC
+ ": Websocket connection closed"
)
def sync_with_repo(self, path, topic):
# TODO
if not self.__ws_connected:
return None
msg = {"topic": topic, "path": path, "value": self.repo_json[path]}
self._ws.send(json.dumps(msg))
def __connect_with_broker(self):
print(BColors.OKBLUE + "[S³I][Broker]" + BColors.ENDC + ": Connect with S3I-Broker")
self.__endpoint = find_broker_endpoint(self.dir, thing_id=self.thing_id)
......@@ -317,7 +271,7 @@ def on_get_value_request(self, msg):
get_value_reply.fillGetValueReply(
senderUUID=self.thing_id,
receiverUUID=[request_sender],
results=json.dumps(value),
results=str(value),
msgUUID=reply_msg_uuid,
replyingToUUID=request_msg_id,
)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment