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
b79247e4
Commit
b79247e4
authored
Nov 07, 2012
by
Taddeüs Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Comment cleanup
parent
09919006
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
11 deletions
+11
-11
frame.py
frame.py
+9
-9
websocket.py
websocket.py
+2
-2
No files found.
frame.py
View file @
b79247e4
...
...
@@ -34,14 +34,14 @@ class Frame(object):
"""
Create a new frame.
`opcode
'
is one of the constants as defined above.
`opcode
`
is one of the constants as defined above.
`payload
'
is a string of bytes containing the data sendt in the frame.
`payload
`
is a string of bytes containing the data sendt in the frame.
`final` is a boolean indicating whether this frame is the last in a
chain of fragments.
`rsv1
', `rsv2' and `rsv3'
are booleans indicating bit values for RSV1,
`rsv1
`, `rsv2` and `rsv3`
are booleans indicating bit values for RSV1,
RVS2 and RSV3, which are only non-zero if defined so by extensions.
"""
if
len
(
masking_key
)
not
in
(
0
,
4
):
...
...
@@ -104,11 +104,11 @@ class Frame(object):
Fragment the frame into a chain of fragment frames, as explained in the
docs of the function receive_fragments().
`fragment_size
'
indicates the maximum payload size of each fragment.
`fragment_size
`
indicates the maximum payload size of each fragment.
The payload of the original frame is split into one or more parts, and
each part is converted to a Frame instance.
`mask
'
is a boolean (default False) indicating whether the payloads
`mask
`
is a boolean (default False) indicating whether the payloads
should be masked. If True, each frame is assigned a randomly generated
masking key.
"""
...
...
@@ -173,7 +173,7 @@ class ControlFrame(Frame):
def
receive_fragments
(
sock
,
control_frame_handler
):
"""
Receive a sequence of frames that belong together on socket `sock
'
:
Receive a sequence of frames that belong together on socket `sock
`
:
- An initial frame with non-zero opcode
- Zero or more frames with opcode = 0 and final = False
- A final frame with opcode = 0 and final = True
...
...
@@ -182,7 +182,7 @@ def receive_fragments(sock, control_frame_handler):
and final = True. Thus, this function returns a list of at least a single
frame.
`control_frame_handler
'
is a callback function taking a single argument,
`control_frame_handler
`
is a callback function taking a single argument,
which is a ControlFrame instance in case a control frame is received (this
may occur in the middle of a fragment chain).
"""
...
...
@@ -205,7 +205,7 @@ def receive_fragments(sock, control_frame_handler):
def
receive_frame
(
sock
):
"""
Receive a single frame on socket `sock
'
. The frame schme is explained in
Receive a single frame on socket `sock
`
. The frame schme is explained in
the docs of Frame.pack().
"""
b1
,
b2
=
struct
.
unpack
(
'!BB'
,
recvn
(
sock
,
2
))
...
...
@@ -240,7 +240,7 @@ def receive_frame(sock):
def
recvn
(
sock
,
n
):
"""
Keep receiving data from `sock
' until exactly `n'
bytes have been read.
Keep receiving data from `sock
` until exactly `n`
bytes have been read.
"""
data
=
''
...
...
websocket.py
View file @
b79247e4
...
...
@@ -22,7 +22,7 @@ class WebSocket(object):
"""
def
__init__
(
self
,
sock
):
"""
`sock
'
is a regular TCP socket instance.
`sock
`
is a regular TCP socket instance.
"""
self
.
sock
=
sock
...
...
@@ -200,7 +200,7 @@ class WebSocket(object):
def
onmessage
(
self
,
message
):
"""
Called when a message is received. `message
'
is a Message object, which
Called when a message is received. `message
`
is a Message object, which
can be constructed from a single frame or multiple fragmented frames.
"""
return
NotImplemented
...
...
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