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
6807fc3f
Commit
6807fc3f
authored
Jul 25, 2013
by
Taddeüs Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed onexception() to onerror(), fixed some typo's
parent
6641c0c4
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
10 deletions
+10
-10
connection.py
connection.py
+2
-2
server.py
server.py
+5
-5
websocket.py
websocket.py
+3
-3
No files found.
connection.py
View file @
6807fc3f
...
...
@@ -111,7 +111,7 @@ class Connection(object):
self
.
onclose
(
None
,
''
)
break
except
Exception
as
e
:
self
.
one
xception
(
e
)
self
.
one
rror
(
e
)
def
send_close
(
self
,
code
,
reason
):
"""
...
...
@@ -191,7 +191,7 @@ class Connection(object):
"""
return
NotImplemented
def
one
xception
(
self
,
e
):
def
one
rror
(
self
,
e
):
"""
Handle a raised exception.
"""
...
...
server.py
View file @
6807fc3f
...
...
@@ -26,7 +26,7 @@ class Server(object):
>>> def onmessage(self, client, message):
>>> # handle message from client
>>> GameServer(
port=
8000).run()
>>> GameServer(8000).run()
"""
def
__init__
(
self
,
port
,
hostname
=
''
,
loglevel
=
logging
.
INFO
,
protocols
=
[]):
...
...
@@ -96,7 +96,7 @@ class Server(object):
logging
.
debug
(
msg
)
def
one
xception
(
self
,
client
,
e
):
def
one
rror
(
self
,
client
,
e
):
logging
.
error
(
format_exc
(
e
))
...
...
@@ -120,8 +120,8 @@ class Client(Connection):
def
onclose
(
self
,
code
,
reason
):
self
.
server
.
remove_client
(
self
,
code
,
reason
)
def
one
xception
(
self
,
e
):
self
.
server
.
one
xception
(
self
,
e
)
def
one
rror
(
self
,
e
):
self
.
server
.
one
rror
(
self
,
e
)
def
__str__
(
self
):
return
'<Client at %s:%d>'
%
self
.
sock
.
getpeername
()
...
...
@@ -129,5 +129,5 @@ class Client(Connection):
if
__name__
==
'__main__'
:
import
sys
port
=
int
(
sys
.
argv
[
1
])
if
len
(
sys
.
argv
)
>
1
else
80
port
=
int
(
sys
.
argv
[
1
])
if
len
(
sys
.
argv
)
>
1
else
80
00
Server
(
port
,
loglevel
=
logging
.
DEBUG
).
run
()
websocket.py
View file @
6807fc3f
...
...
@@ -21,7 +21,7 @@ class websocket(object):
Server example:
>>> sock = websocket()
>>> sock.bind(('', 80))
>>> sock.bind(('', 80
00
))
>>> sock.listen()
>>> client = sock.accept()
...
...
@@ -30,7 +30,7 @@ class websocket(object):
Client example:
>>> sock = websocket()
>>> sock.connect(('
kompiler.org', 8
0))
>>> sock.connect(('
', 800
0))
"""
def
__init__
(
self
,
protocols
=
[],
extensions
=
[],
sfamily
=
socket
.
AF_INET
,
sproto
=
0
):
...
...
@@ -57,7 +57,7 @@ class websocket(object):
"""
Equivalent to socket.accept(), but transforms the socket into a
websocket instance and sends a server handshake (after receiving a
client handshake). Note that the handshake may raise a
n
HandshakeError
client handshake). Note that the handshake may raise a HandshakeError
exception.
"""
sock
,
address
=
self
.
sock
.
accept
()
...
...
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