Giter Club home page Giter Club logo

Comments (3)

Jakky89 avatar Jakky89 commented on August 20, 2024

I think its the PacketHandler in packet.py. Rewriting it could help. This is what I have done now (not tested). Would be great if someone could make suggestions how to make it better:

    def feed(self, data):
        try:
            self.data += data
            reader = ByteReader(self.data)
            while True:
                pos = reader.tell()
                if pos >= len(self.data):
                    break
                packet = read_packet(reader, self.table)
                self.last_packet_id = packet.packet_id
                self.callback(packet)
            self.data = self.data[pos:]
        except (OutOfData, KeyError):
            pass

For comparisation here is the old source (looks buggy and unperformant because also the try is used within a while loop):

    def feed(self, data):
        self.data += data
        reader = ByteReader(self.data)
        while True:
            pos = reader.tell()
            if pos >= len(self.data):
                break
            try:
                packet = read_packet(reader, self.table)
            except OutOfData:
                break
            except KeyError, e:
                print 'Last packet ID:', self.last_packet_id
                raise e
            self.last_packet_id = packet.packet_id
            self.callback(packet)
        self.data = self.data[pos:]

from cuwo.

matpow2 avatar matpow2 commented on August 20, 2024

No - that's not how it works. What you have provided above will break the framing.
Also, this is a duplicate of #25

from cuwo.

Jakky89 avatar Jakky89 commented on August 20, 2024

Why it should not work with my code change?

from cuwo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.