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
92410324
Commit
92410324
authored
Jul 25, 2013
by
Taddeüs Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added missing close() method, typing bugfix, removed debug code
parent
57af2bf1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
7 deletions
+11
-7
connection.py
connection.py
+6
-3
frame.py
frame.py
+2
-2
websocket.py
websocket.py
+3
-2
No files found.
connection.py
View file @
92410324
...
@@ -105,7 +105,6 @@ class Connection(object):
...
@@ -105,7 +105,6 @@ class Connection(object):
self
.
onmessage
(
self
.
receive
())
self
.
onmessage
(
self
.
receive
())
except
SocketClosed
as
e
:
except
SocketClosed
as
e
:
self
.
close
()
self
.
close
()
#self.onclose(e.code, e.reason)
break
break
except
Exception
as
e
:
except
Exception
as
e
:
self
.
onerror
(
e
)
self
.
onerror
(
e
)
...
@@ -124,7 +123,11 @@ class Connection(object):
...
@@ -124,7 +123,11 @@ class Connection(object):
Close the socket by sending a CLOSE frame and waiting for a response
Close the socket by sending a CLOSE frame and waiting for a response
close message, unless such a message has already been received earlier
close message, unless such a message has already been received earlier
(prior to calling this function, for example). The onclose() handler is
(prior to calling this function, for example). The onclose() handler is
called after the response has been received.
called after the response has been received, but before the socket is
actually closed. This order was chosen to prevent errors in
stringification in the onclose() handler. For example,
socket.getpeername() raises a Bad file descriptor error then the socket
is closed.
"""
"""
# Send CLOSE frame
# Send CLOSE frame
payload
=
''
if
code
is
None
else
struct
.
pack
(
'!H'
,
code
)
+
reason
payload
=
''
if
code
is
None
else
struct
.
pack
(
'!H'
,
code
)
+
reason
...
@@ -145,8 +148,8 @@ class Connection(object):
...
@@ -145,8 +148,8 @@ class Connection(object):
# CLOSE frame is received, so that a fragmented chain may arrive
# CLOSE frame is received, so that a fragmented chain may arrive
# fully first
# fully first
self
.
sock
.
close
()
self
.
onclose
(
code
,
reason
)
self
.
onclose
(
code
,
reason
)
self
.
sock
.
close
()
def
onopen
(
self
):
def
onopen
(
self
):
"""
"""
...
...
frame.py
View file @
92410324
...
@@ -177,8 +177,8 @@ class ControlFrame(Frame):
...
@@ -177,8 +177,8 @@ class ControlFrame(Frame):
is given, the code is None and the reason is an empty string.
is given, the code is None and the reason is an empty string.
"""
"""
if
self
.
payload
:
if
self
.
payload
:
code
=
struct
.
unpack
(
'!H'
,
s
elf
.
payload
[:
2
]
)
code
=
struct
.
unpack
(
'!H'
,
s
tr
(
self
.
payload
[:
2
])
)
reason
=
s
elf
.
payload
[
2
:]
reason
=
s
tr
(
self
.
payload
[
2
:])
else
:
else
:
code
=
None
code
=
None
reason
=
''
reason
=
''
...
...
websocket.py
View file @
92410324
...
@@ -81,7 +81,6 @@ class websocket(object):
...
@@ -81,7 +81,6 @@ class websocket(object):
Send a number of frames.
Send a number of frames.
"""
"""
for
frame
in
args
:
for
frame
in
args
:
print
'send frame:'
,
frame
,
'to %s:%d'
%
self
.
sock
.
getpeername
(),
frame
.
payload
self
.
sock
.
sendall
(
frame
.
pack
())
self
.
sock
.
sendall
(
frame
.
pack
())
def
recv
(
self
):
def
recv
(
self
):
...
@@ -90,7 +89,6 @@ class websocket(object):
...
@@ -90,7 +89,6 @@ class websocket(object):
frame.
frame.
"""
"""
frame
=
receive_frame
(
self
.
sock
)
frame
=
receive_frame
(
self
.
sock
)
print
'receive frame:'
,
frame
,
'from %s:%d'
%
self
.
sock
.
getpeername
()
return
frame
return
frame
def
recvn
(
self
,
n
):
def
recvn
(
self
,
n
):
...
@@ -112,6 +110,9 @@ class websocket(object):
...
@@ -112,6 +110,9 @@ class websocket(object):
def
getsockopt
(
self
,
level
,
optname
):
def
getsockopt
(
self
,
level
,
optname
):
return
self
.
sock
.
getsockopt
(
level
,
optname
)
return
self
.
sock
.
getsockopt
(
level
,
optname
)
def
close
(
self
):
self
.
sock
.
close
()
def
server_handshake
(
self
):
def
server_handshake
(
self
):
"""
"""
Execute a handshake as the server end point of the socket. If the HTTP
Execute a handshake as the server end point of the socket. If the HTTP
...
...
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