Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

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.

Comment on Dangerous method? Protocol::WebSocket::Frame::to_string
Select or Download Code
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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1035978]
Approved by Old_Gray_Bear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2015-07-05 03:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls