AnyEven...Message(3)

πŸ’– AnyEvent::WebSocket::Message β€” WebSocket message for AnyEvent πŸ’–

okay so bestie, the page header says AnyEven...Message(3) and it lives on the User Contributed Perl Documentation shelf. The actual main character is AnyEvent::WebSocket::Message, and we're about to go through every single detail together, no cap. 🫢


πŸŽ€ NAME πŸŽ€

AnyEvent::WebSocket::Message β€” WebSocket message for AnyEvent. That's the name and the whole assignment, periodt. πŸ’…

✨ VERSION ✨

version 0.55 β€” yes, that exact version, don't @ me. ✨

🌸 SYNOPSIS 🌸

okay so here's the whole send-and-receive situation in code, copied exactly:

$connection->send(
  AnyEvent::WebSocket::Message->new(body => "some message"),
);

$connection->on(each_message => sub {
  my($connection, $message) = @_;
  if($message->is_text || $message->is_binary)
  {
    my $body = $message->body;
  }
});

πŸ’« DESCRIPTION πŸ’«

Instances of this class represent a single WebSocket message. They're literally the objects that come through from the other end of your AnyEvent::WebSocket::Connection instance. You can also send them through that class using its send method. It's giving message-object main character energy, fr fr. πŸ¦‹

πŸ¦‹ ATTRIBUTES πŸ¦‹

body

The body or payload of the message. That's the snack inside the envelope. πŸ“

opcode

The integer code for the type of message. It's the little number that says what kind of message this is. πŸ”₯

πŸ’… METHODS πŸ’…

decoded_body

my $body = $message->decoded_body;

Returns the body decoded from UTF-8. So you get the decoded body back, slay. ✨

is_text

my $bool = $message->is_text;

True if the message is text. πŸ’–

is_binary

my $bool = $message->is_binary;

True if the message is binary. 🌈

is_close

my $bool = $message->is_close;

True if the message is a close message. πŸ‘‘

is_ping

my $bool = $message->is_ping

True if the message is a ping. ⭐

is_pong

my $bool = $message->is_pong;

True if the message is a pong. πŸŽ€

πŸ‘‘ SEE ALSO πŸ‘‘

πŸ’– AUTHOR πŸ’–

Author: Graham Ollis <plicease@cpan.org>

Contributors:

  • Toshio Ito (debug-ito, TOSHIOITO)
  • JosΓ© JoaquΓ­n Atria (JJATRIA)
  • Kivanc Yazan (KYZN)
  • Yanick Champoux (YANICK)
  • Fayland Lam (FAYLAND)
  • Daniel Kamil Kozar (xavery)

This software is copyright (c) 2013-2022 by Graham Ollis.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.


✨ cute sign-off: this page was served with perl v5.42.0, dated 2023-05-05, and the footer header is AnyEven...Message(3). byeee bestie, go slay those WebSocket messages πŸ’…πŸ’–

πŸ“¦ where this page comes from