FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-orientation-visualization-app/SocketCommands.py at master · nelsonwenner/python-orientation-visualization-app · GitHub
nelsonwenner
/
python-orientation-visualization-app
Public
Notifications
You must be signed in to change notification settings
Fork
5
Star
15
Code
Issues
3
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
python-orientation-visualization-app
/
SocketCommands.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
45 lines (37 loc) · 1.26 KB
Breadcrumbs
python-orientation-visualization-app
/
SocketCommands.py
Copy path
File metadata and controls
45 lines (37 loc) · 1.26 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from
websocket_server
import
WebsocketServer
class
SocketCommands
:
def
__init__
(
self
,
host
=
'0.0.0.0'
,
port
=
8080
):
self
.
host
=
host
self
.
port
=
port
self
.
server
=
None
self
.
data
=
None
self
.
clients
=
[]
def
connect
(
self
):
self
.
server
=
WebsocketServer
(
self
.
port
,
self
.
host
)
self
.
server
.
set_fn_new_client
(
self
.
new_client
)
self
.
server
.
set_fn_client_left
(
self
.
client_left
)
self
.
server
.
set_fn_message_received
(
self
.
message_received
)
self
.
server
.
serve_forever
()
def
new_client
(
self
,
client
,
server
):
current_client
=
str
(
client
[
'id'
])
message
=
'[X] A new client connected of id: {}'
.
format
(
current_client
)
self
.
clients
.
append
(
message
)
def
client_left
(
self
,
client
,
server
):
current_client
=
str
(
client
[
'id'
])
message
=
'[X] Client disconnected of id: {}'
.
format
(
current_client
)
self
.
clients
.
append
(
message
)
def
message_received
(
self
,
client
,
server
,
message
):
self
.
data
=
message
def
is_connect
(
self
):
return
self
.
server
is
not
None
def
get_data
(
self
):
if
not
self
.
data
:
return
None
else
:
return
self
.
data
.
split
(
','
)
def
disconnect
(
self
):
if
self
.
server
is
None
:
return
self
.
server
.
server_close
()
self
.
server
=
None
self
.
data
=
None
self
.
clients
=
[]
Back
|
FazBrowse Home
|
New Git URL