From d781d857452588fff238fda15f6663744d9eac0e Mon Sep 17 00:00:00 2001 From: CodePanter Date: Thu, 7 Apr 2016 20:56:28 +0200 Subject: [PATCH] Fixed the problem with pixels missing in the message and prevented general exceptions from crashing the server. --- client.py | 4 +--- vloed.py | 47 +++++++++++++++++++++++++---------------------- 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/client.py b/client.py index 96d8627..9a4dbbb 100755 --- a/client.py +++ b/client.py @@ -14,7 +14,6 @@ import random import time class MaxSizeList(list): - maxsize = 0 def __init__(self, maxcount=100): self.maxsize = maxcount @@ -25,7 +24,6 @@ class MaxSizeList(list): if self.__len__() == self.maxsize: raise IndexError('max size reached') - def RGBPixel(x, y, r, g, b, a=None): # pylint: disable=C0103 """Generates the packed data for a pixel""" if a: @@ -55,7 +53,7 @@ def RandomFill(width=640, height=480): message.append(pixel) except IndexError: yield ''.join(message) - message[:] = [] + message[2:] = [] message.append(pixel) yield ''.join(message) diff --git a/vloed.py b/vloed.py index 4209857..b232cc3 100755 --- a/vloed.py +++ b/vloed.py @@ -35,7 +35,7 @@ class Canvas(object): self.screen = None self.udp_ip = UDP_IP self.udp_port = UDP_PORT - self.canvas() + self.canvas() self.set_title() self.queue = queue self.limit = 140 @@ -86,31 +86,34 @@ class Canvas(object): # indicat that nothing was done, and w can skip flipping the screen return False #access the pixel array and lock it - self.pixels = pygame.surfarray.pixels2d(self.screen) + self.pixels = pygame.surfarray.pixels2d(self.screen) returntime = time.time() + (1.0 / self.fps) - # while we have stuff in the queue, and its not our next time to draw a + # while we have stuff in the queue, and its not our next time to draw a # frame, lets process packets from the queue while time.time() < returntime and not self.queue.empty(): - data = self.queue.get() - preamble = struct.unpack_from("