Add definable buffer size of data

This commit is contained in:
Fierelier 2023-11-01 00:45:56 +01:00
parent af3f6c8124
commit 65c68cb6d0
2 changed files with 13 additions and 2 deletions

View File

@ -12,6 +12,7 @@ Accepts data from stdin, and sends it to the specified server.
- **`user-password`**: Your user's password.
- **`channel`**: The channel you wanna stream to. Can be any name. Defaults to default.
- **`channel-password`**: The channel's password. Can be any password. Defaults to no password.
- **`bufsize`**: The size of chunks. Defaults to 0 (no set size, lowest delay).
All arguments are optional but for `user` and `user-password`.

View File

@ -29,12 +29,22 @@ def clientLoopIn(self):
if cmd[0] == "broadcast":
if not authenticate(args["user"],args["user-password"]): return
if not "bufsize" in args:
bufsize = 0
else:
bufsize = int(args["bufsize"])
if bufsize < 0: bufsize = 0
if bufsize > maxBuffer: bufsize = maxBuffer
buffer = getClientData(self.cID,"buffer")
packet = -1
packetMin = 0
bufferSize = 0
while True:
data = self.connection.recv(connBuffer)
if bufsize == 0:
data = self.connection.recv(connBuffer)
else:
data = recv(self.connection,bufsize)
if data == b"": return
with clientDataLock:
dataSize = len(data)
@ -76,4 +86,4 @@ def clientLoopIn(self):
packet += 1
with clientDataLock:
data = getClientData(watchID,"buffer")[str(packet)]
self.connection.sendall(data)
self.connection.sendall(data)