Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Dangerous method? Protocol::WebSocket::Frame::to_string

by Riales (Hermit)
on May 30, 2013 at 06:54 UTC ( #1035978=perlquestion: print w/replies, xml ) Need Help??
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 :)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1035978]
Approved by Old_Gray_Bear
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2018-05-27 02:16 GMT
Find Nodes?
    Voting Booth?