Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fml40-reference-implementation
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
KWH40
fml40-reference-implementation
Commits
a2fbd1d1
Commit
a2fbd1d1
authored
4 years ago
by
Jiahang Chen
Browse files
Options
Downloads
Patches
Plain Diff
delete websocket
parent
447146c5
No related branches found
No related tags found
1 merge request
!4
Dev chen
Pipeline
#349040
passed
4 years ago
Stage: build_wheel
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ml/thing.py
+1
-47
1 addition, 47 deletions
ml/thing.py
with
1 addition
and
47 deletions
ml/thing.py
+
1
−
47
View file @
a2fbd1d1
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
,
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment