Skip to content

Commit

Permalink
More cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
taras committed Aug 20, 2024
1 parent 5404fb9 commit fddcec9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions picows/picows.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ cdef class WSTransport:
bint _is_client_side

cdef send_reuse_external_buffer(self, WSMsgType msg_type, char* message, size_t message_size)
cpdef send(self, WSMsgType msg_type, message)
cpdef send(self, WSMsgType msg_type, message, bint rsv1=*)
cpdef send_ping(self, message=*)
cpdef send_pong(self, message=*)
cpdef send_close(self, WSCloseCode close_code=*, close_message=*)
Expand All @@ -102,7 +102,7 @@ cdef class WSTransport:
cdef _mark_disconnected(self)

cdef bytes _prepare_frame_in_external_buffer(self, WSMsgType msg_type, uint8_t* msg_ptr, size_t msg_length)
cdef bytes _prepare_frame(self, WSMsgType msg_type, message)
cdef bytes _prepare_frame(self, WSMsgType msg_type, message, bint rsv1)


cdef class WSListener:
Expand Down
9 changes: 6 additions & 3 deletions picows/picows.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -319,14 +319,17 @@ cdef class WSTransport:
frame = self._prepare_frame_in_external_buffer(msg_type, <uint8_t*>message, message_size)
self.underlying_transport.write(frame)

cpdef send(self, WSMsgType msg_type, message):
cpdef send(self, WSMsgType msg_type, message, bint rsv1=False):
"""
:param msg_type: :any:`WSMsgType` enum value\n
:param message: an optional bytes-like object
:param rsv1: first reserved bit in websocket frame.
Some protocol extensions use it to indicate that the payload is
compressed.
Send a frame over websocket with a message as its payload.
"""
frame = self._prepare_frame(msg_type, message)
frame = self._prepare_frame(msg_type, message, rsv1)
self.underlying_transport.write(frame)

cpdef send_ping(self, message=None):
Expand Down Expand Up @@ -478,7 +481,7 @@ cdef class WSTransport:

return PyBytes_FromStringAndSize(<char*>header_ptr, total_length)

cdef bytes _prepare_frame(self, WSMsgType msg_type, message):
cdef bytes _prepare_frame(self, WSMsgType msg_type, message, bint rsv1):
"""Send a frame over the websocket with message as its payload."""
cdef:
Py_buffer msg_buffer
Expand Down

0 comments on commit fddcec9

Please sign in to comment.