Skip to content

Commit

Permalink
fix: _buffer use javascript syntax (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
Multu authored Jan 31, 2024
1 parent d5e5c6f commit 5cfd335
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/peerjs/dataconnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def _apply_options(
self._negotiator: Negotiator = None
self.stringify = lambda data: json.dumps(data)
self.parse = lambda jsn: json.loads(jsn)
self._buffer: []
self._buffer = []
self._bufferSize = 0
self._buffering = False
self._chunkedData = {}
Expand Down Expand Up @@ -287,8 +287,8 @@ async def send(self, data, chunked: bool = False) -> None:

async def _bufferedSend(self, msg: any) -> None:
if self._buffering or not await self._trySend(msg):
self._buffer.push(msg)
self._bufferSize = self._buffer.length
self._buffer.append(msg)
self._bufferSize = len(self._buffer)

async def _trySend(self, msg) -> bool:
"""Return true if the send succeeds."""
Expand Down Expand Up @@ -320,14 +320,14 @@ def _tryBuffer(self) -> None:
"""Try to send the first message in the buffer."""
if not self.open:
return
if self._buffer.length == 0:
if len(self._buffer) == 0:
return

msg = self._buffer[0]

if self._trySend(msg):
self._buffer.shift()
self._bufferSize = self._buffer.length
self._buffer.pop()
self._bufferSize = len(self._buffer)
self._tryBuffer()

# def _sendChunks(self, blob: Blob) -> None:
Expand Down

0 comments on commit 5cfd335

Please sign in to comment.