Riales has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks!

I was using Protocol::WebSocket::Frame and noticed that if you try to use its to_string method, it dies with the message DO NOT USE.

Anybody know why? It looks like it fulfills a fairly benign function - it just wraps its current buffer with \x00 and \xff...

Also, anybody know the proper way to send a websocket message if not with the to_string method in this module?

Many thanks in advance!

EDIT: Figured out the proper way (or at least a way that works) - using the to_bytes method instead of the to_string method works beautifully. My vague guess is that it has something to do with encodings, but I would love if somebody that knew more would enlighten me.

Replies are listed 'Best First'.
Re: Dangerous method? Protocol::WebSocket::Frame::to_string
by Anonymous Monk on May 30, 2013 at 08:26 UTC

    Anybody know why?

    Because its drawn that way?

    sub to_string { my $self = shift; die 'DO NOT USE'; if ( $self->version eq 'draft-hixie-75' || $self->version eq 'draft-ietf-hybi-00') { return "\x00" . Encode::decode('UTF-8', $self->{buffer}) . "\x +ff"; } }

    The method isn't documented, so pretend that it doesn't exist :)