Esempio n. 1
0
    def process_data(self, data):
        bs = BinaryStream(data)

        msgtype = bs.read_byte()

        if msgtype == MESSAGE:
            print "MESSAGE"
            msg = bs.read_string()
            self.broadcast(self.get_datas_message(msg))

        elif msgtype == PLAYPAUSE:
            print "PLAYPAUSE"
            self.broadcast(self.get_datas_playpause(), self)

        elif msgtype == MOVIE_TIME:
            print "MOVIE_TIME"
            t = bs.read_int32()

            # broadcast
            for client in self.clients:
                if client is self: continue
                new_t = self.ping / 2 + client.ping / 2 + t
                print "new_t", new_t
                client.sendLine(self.get_datas_slider_update(new_t))

        elif msgtype == PING:
            self.pings.append(time.time() - self.ping_check_time)
            if len(self.pings) > 50:
                del self.pings[0]
Esempio n. 2
0
    def process_data(self, data, client=None):
        bs = BinaryStream(data)

        msgtype = bs.read_byte()

        if msgtype == MESSAGE:
            msg = bs.read_string()
            self.player.update_chat(msg)

        elif msgtype == PLAYPAUSE:
            self.player.play_pause()

        elif msgtype == MOVIE_TIME:
            t = bs.read_int32()
            print "movietime", t
            self.player.change_pos_from_net(t)  # t already smoothed

        elif msgtype == PING:
            self.sendLine(self.get_datas_ping())