def serve(self):
    while True:
        print('Waiting for connection...')
        self.server.listen(1)
        (self.socket, addr) = self.server.accept()
        print('Client connected', addr)
        self.socket.send(b'BoldUI\x00\x01')
        header = self.socket.recv(8)
        if (header != b'BoldUI\x00\x01'):
            print('Invalid header, disconnecting')
            break
        print('Handshake complete, sending initial scene')
        if self.scene:
            self._send_scene()
        for var in self.pending_vars:
            self.set_remote_var(var, self.pending_vars[var][0], self.pending_vars[var][1])
        print(f'Server PID is {os.getpid()}')
        while True:
            packet = b''
            packet_length = self.socket.recv(4)
            if (not packet_length):
                break
            packet_length = int.from_bytes(packet_length, 'big')
            while (len(packet) < packet_length):
                packet += self.socket.recv((packet_length - len(packet)))
                if (not packet):
                    break
            self._handle_packet(packet)
        print('Client disconnected')
        break
def serve(self):
    while True:
        print('Waiting for connection...')
        self.server.listen(1)
        (self.socket, addr) = self.server.accept()
        print('Client connected', addr)
        self.socket.send(b'BoldUI\x00\x01')
        header = self.socket.recv(8)
        if (header != b'BoldUI\x00\x01'):
            print('Invalid header, disconnecting')
            break
        print('Handshake complete, sending initial scene')
        if self.scene:
            self._send_scene()
        for var in self.pending_vars:
            self.set_remote_var(var, self.pending_vars[var][0], self.pending_vars[var][1])
        print(f'Server PID is {os.getpid()}')
        while True:
            packet = b
            packet_length = self.socket.recv(4)
            if (not packet_length):
                break
            packet_length = int.from_bytes(packet_length, 'big')
            while (len(packet) < packet_length):
                packet += self.socket.recv((packet_length - len(packet)))
                if (not packet):
                    break
            self._handle_packet(packet)
        print('Client disconnected')
        break