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

Add a way to decode binary frames #23

Closed
davidcole1340 opened this issue Mar 15, 2016 · 2 comments
Closed

Add a way to decode binary frames #23

davidcole1340 opened this issue Mar 15, 2016 · 2 comments

Comments

@davidcole1340
Copy link
Contributor

At the moment there is no way to decode binary frames (opcode 2) which is why I had to import the code into my project. Perhaps there should be a way to decode the binary frames?

I am using this code:

if ($this->_message->getOpcode() == Frame::OP_BINARY) {
    $message = zlib_decode($message);
}

however, this won't work with all encodings.

@cboden
Copy link
Member

cboden commented Mar 15, 2016

I haven't used binary frames in practice yet and only understand the differences at the protocol level. I know browsers handle two types, blob and byte stream, but I'm not sure of their practical usages. I'm not sure how to code to handle all scenarios. Do you have any suggestions?

Also you should be able to do this:

$conn->on('message', function(MessageInterface $msg) {
    if ($msg->isBinary()) {
        $payload = zlib_decode($msg->getPayload());
    }
});

@davidcole1340
Copy link
Contributor Author

Ah ok, didn't realise in the new version that it passed through the message instead of just the payload. I will give it a go soon.

@cboden cboden closed this as completed Mar 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants