1Mojo::Transaction::WebSUoscekretC(o3n)tributed Perl DocuMmoejnot:a:tTiroannsaction::WebSocket(3)
2
3
4
6 Mojo::Transaction::WebSocket - WebSocket Transaction Container
7
9 use Mojo::Transaction::WebSocket;
10
12 Mojo::Transaction::WebSocket is a container for WebSocket transactions
13 as described in "The WebSocket protocol".
14
16 Mojo::Transaction::WebSocket inherits all attributes from
17 Mojo::Transaction and implements the following new ones.
18
19 "handshake"
20 my $handshake = $ws->handshake;
21 $ws = $ws->handshake(Mojo::Transaction::HTTP->new);
22
23 The original handshake transaction.
24
25 "receive_message"
26 my $cb = $ws->receive_message;
27 $ws = $ws->receive_message(sub {...});
28
29 The callback that receives decoded messages one by one.
30
31 $ws->receive_message(sub {
32 my ($self, $message) = @_;
33 });
34
36 Mojo::Transaction::WebSocket inherits all methods from
37 Mojo::Transaction and implements the following new ones.
38
39 "client_challenge"
40 my $success = $ws->client_challenge;
41
42 Check WebSocket handshake challenge, only used by client. Note that
43 this method is EXPERIMENTAL and might change without warning!
44
45 "client_close"
46 $ws = $ws->client_close;
47
48 Connection got closed, only used by clients.
49
50 "client_handshake"
51 $ws = $ws->client_handshake;
52
53 WebSocket handshake, only used by clients. Note that this method is
54 EXPERIMENTAL and might change without warning!
55
56 "client_read"
57 $ws = $ws->client_read($data);
58
59 Read raw WebSocket data, only used by clients.
60
61 "client_write"
62 my $chunk = $ws->client_write;
63
64 Raw WebSocket data to write, only used by clients.
65
66 "connection"
67 my $connection = $ws->connection;
68
69 The connection this websocket is using.
70
71 "finish"
72 $ws->finish;
73
74 Finish the WebSocket connection gracefully.
75
76 "is_websocket"
77 my $is_websocket = $ws->is_websocket;
78
79 True.
80
81 "local_address"
82 my $local_address = $ws->local_address;
83
84 The local address of this WebSocket.
85
86 "local_port"
87 my $local_port = $ws->local_port;
88
89 The local port of this WebSocket.
90
91 "remote_address"
92 my $remote_address = $ws->remote_address;
93
94 The remote address of this WebSocket.
95
96 "remote_port"
97 my $remote_port = $ws->remote_port;
98
99 The remote port of this WebSocket.
100
101 "req"
102 my $req = $ws->req;
103
104 The original handshake request.
105
106 "res"
107 my $req = $ws->res;
108
109 The original handshake response.
110
111 "send_message"
112 $ws->send_message('Hi there!');
113
114 Send a message over the WebSocket, encoding and framing will be handled
115 transparently.
116
117 "server_handshake"
118 $ws = $ws->server_handshake;
119
120 WebSocket handshake, only used by servers. Note that this method is
121 EXPERIMENTAL and might change without warning!
122
123 "server_read"
124 $ws = $ws->server_read($data);
125
126 Read raw WebSocket data, only used by servers.
127
128 "server_write"
129 my $chunk = $ws->server_write;
130
131 Raw WebSocket data to write, only used by servers.
132
134 Mojolicious, Mojolicious::Guides, <http://mojolicious.org>.
135
136
137
138perl v5.12.3 2010-08-14 Mojo::Transaction::WebSocket(3)