Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
wspy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
wspy
Commits
3c5d9c4a
Commit
3c5d9c4a
authored
Nov 07, 2012
by
Taddeüs Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Default handlers of Client now log events
parent
22dd594f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
8 deletions
+13
-8
server.py
server.py
+13
-8
No files found.
server.py
View file @
3c5d9c4a
...
...
@@ -40,22 +40,21 @@ class Server(object):
def
onopen
(
self
,
client
):
"""
Called
when a new client connects
.
Called
after `client' has completed its handshake
.
"""
pass
logging
.
debug
(
'Opened socket to client %s'
%
client
)
def
onmessage
(
self
,
client
,
message
):
"""
Called when a message is received from some client. `message' is a
Message object
Called when Message object `message' is received from `client'.
"""
return
NotImplemented
logging
.
debug
(
'Received %s from %s'
%
(
message
,
client
))
def
onclose
(
self
,
client
):
"""
Called when
a client
disconnects.
Called when
`client'
disconnects.
"""
pass
logging
.
debug
(
'Closed socket to client %s'
%
client
)
class
Client
(
WebSocket
):
...
...
@@ -69,6 +68,12 @@ class Client(WebSocket):
def
onmessage
(
self
,
message
):
self
.
server
.
onmessage
(
self
,
message
)
def
onping
(
self
,
payload
):
logging
.
debug
(
'Sent ping "%s" to %s'
%
(
payload
,
self
))
def
onpong
(
self
,
payload
):
logging
.
debug
(
'Received pong "%s" from %s'
%
(
payload
,
self
))
def
onclose
(
self
):
self
.
server
.
onclose
(
self
)
...
...
@@ -79,4 +84,4 @@ class Client(WebSocket):
if
__name__
==
'__main__'
:
import
sys
port
=
int
(
sys
.
argv
[
1
])
if
len
(
sys
.
argv
)
>
1
else
80
Server
(
port
=
port
,
log_level
=
logging
.
DEBUG
).
run
()
Server
(
port
,
log_level
=
logging
.
DEBUG
).
run
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment