Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decode broken when multiple calls same time #59

Open
GoogleCodeExporter opened this issue Dec 17, 2015 · 0 comments
Open

Decode broken when multiple calls same time #59

GoogleCodeExporter opened this issue Dec 17, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?

Send two frames in a very short time
  socket.send('message1')
  socket.send('message2')

As result, the decoding function does not understand when first frame end and 
second one start, which causes it handle two frame as single. This lead broken 
output.

Decode function is:
    private function decode ($msg) {
        $len = $data = $decoded = $index = null;
        $len = $msg[1] & 127;
        if ($len === 126) {
            $this->masks = substr ($msg, 4, 4);
            $data = substr ($msg, 8);
            $this->initFrame = substr ($msg, 0, 4);
        }
        else if ($len === 127) {
            $this->masks = substr ($msg, 10, 4);
            $data = substr ($msg, 14);
            $this->initFrame = substr ($msg, 0, 10);
        }
        else {
            $this->masks = substr ($msg, 2, 4);
            $data = substr ($msg, 6);
            $this->initFrame = substr ($msg, 0, 2);
        }
        for ($index = 0; $index < strlen ($data); $index++) {
            $decoded .= $data[$index] ^ $this->masks[$index % 4];
        }
        return $decoded;
    }
----------------

Should there be some regonizion when frame end and then attach rest of the 
message to second frame?

Original issue reported on code.google.com by [email protected] on 15 Nov 2012 at 9:35

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant