1 {{+bindTo:partials.standard_nacl_article}}
2 <h1>pp::WebSocket Class Reference</h1>
4 <!-- Generated by Doxygen 1.7.6.1 -->
10 <div class="contents">
11 <!-- doxytag: class="pp::WebSocket" --><!-- doxytag: inherits="pp::Resource" --><div class="dynheader">
12 Inheritance diagram for pp::WebSocket:</div>
13 <div class="dyncontent">
14 <div class="center"><img src="classpp_1_1_web_socket__inherit__graph.png" border="0" usemap="#pp_1_1_web_socket_inherit__map" alt="Inheritance graph" /></div>
15 <map name="pp_1_1_web_socket_inherit__map" id="pp_1_1_web_socket_inherit__map">
16 <area shape="rect" id="node2" href="classpp_1_1_resource.html" title="A reference counted module resource." alt="" coords="11,5,115,35"></area></map>
17 <center><span class="legend">[<a href="graph_legend.html">legend</a>]</span></center></div>
18 <p><a href="classpp_1_1_web_socket-members.html">List of all members.</a></p>
20 Public Member Functions</h2><table class="memberdecls">
22 <tr><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classpp_1_1_web_socket.html#aeaac3a412a9015a9378beec9f42d5809">WebSocket</a> (const <a class="el" href="classpp_1_1_instance_handle.html">InstanceHandle</a> &instance)</td></tr>
23 <tr><td class="memItemLeft" align="right" valign="top">virtual </td><td class="memItemRight" valign="bottom"><a class="el" href="classpp_1_1_web_socket.html#aa4810e4b945c1fc92493dc206eb35c09">~WebSocket</a> ()</td></tr>
24 <tr><td class="memItemLeft" align="right" valign="top">int32_t </td><td class="memItemRight" valign="bottom"><a class="el" href="classpp_1_1_web_socket.html#ad8471399bfca7df23b87ded733d53141">Connect</a> (const <a class="el" href="classpp_1_1_var.html">Var</a> &url, const <a class="el" href="classpp_1_1_var.html">Var</a> protocols[], uint32_t protocol_count, const <a class="el" href="classpp_1_1_completion_callback.html">CompletionCallback</a> &callback)</td></tr>
25 <tr><td class="memItemLeft" align="right" valign="top">int32_t </td><td class="memItemRight" valign="bottom"><a class="el" href="classpp_1_1_web_socket.html#ae7913ea4019cc2a10c9a0390c5959071">Close</a> (uint16_t code, const <a class="el" href="classpp_1_1_var.html">Var</a> &reason, const <a class="el" href="classpp_1_1_completion_callback.html">CompletionCallback</a> &callback)</td></tr>
26 <tr><td class="memItemLeft" align="right" valign="top">int32_t </td><td class="memItemRight" valign="bottom"><a class="el" href="classpp_1_1_web_socket.html#a1eb972115700589ebf6998db4f411c56">ReceiveMessage</a> (<a class="el" href="classpp_1_1_var.html">Var</a> *message, const <a class="el" href="classpp_1_1_completion_callback.html">CompletionCallback</a> &callback)</td></tr>
27 <tr><td class="memItemLeft" align="right" valign="top">int32_t </td><td class="memItemRight" valign="bottom"><a class="el" href="classpp_1_1_web_socket.html#a276b1aae76ba9d899475aaf9c2cd4f28">SendMessage</a> (const <a class="el" href="classpp_1_1_var.html">Var</a> &message)</td></tr>
28 <tr><td class="memItemLeft" align="right" valign="top">uint64_t </td><td class="memItemRight" valign="bottom"><a class="el" href="classpp_1_1_web_socket.html#aee920e33ef266c51ffdaeba8d6924e19">GetBufferedAmount</a> ()</td></tr>
29 <tr><td class="memItemLeft" align="right" valign="top">uint16_t </td><td class="memItemRight" valign="bottom"><a class="el" href="classpp_1_1_web_socket.html#ab1bb565b7800fd3c147177e4e3a3466f">GetCloseCode</a> ()</td></tr>
30 <tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="classpp_1_1_var.html">Var</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classpp_1_1_web_socket.html#a27c9cf6d130706fcc5e6fe2f9ed51a7b">GetCloseReason</a> ()</td></tr>
31 <tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classpp_1_1_web_socket.html#a092b63f716b3e02fc8ec0696ac58df84">GetCloseWasClean</a> ()</td></tr>
32 <tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="classpp_1_1_var.html">Var</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classpp_1_1_web_socket.html#ab22093b22b7ceea6957047e1cb5967d2">GetExtensions</a> ()</td></tr>
33 <tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="classpp_1_1_var.html">Var</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classpp_1_1_web_socket.html#a1c4b81bb05d30fdef67a07ac904abf0f">GetProtocol</a> ()</td></tr>
34 <tr><td class="memItemLeft" align="right" valign="top">PP_WebSocketReadyState </td><td class="memItemRight" valign="bottom"><a class="el" href="classpp_1_1_web_socket.html#afa09ce5acb5f7f168f17b8b3f5939317">GetReadyState</a> ()</td></tr>
35 <tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="classpp_1_1_var.html">Var</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classpp_1_1_web_socket.html#ab76ccebfe20facff03464e71f4af7719">GetURL</a> ()</td></tr>
37 <hr /><a name="details" id="details"></a><h2>Detailed Description</h2>
38 <div class="textblock"><p>The <code><a class="el" href="classpp_1_1_web_socket.html" title="The WebSocket class providing bi-directional, full-duplex, communications over a single TCP socket...">WebSocket</a></code> class providing bi-directional, full-duplex, communications over a single TCP socket. </p>
39 </div><hr /><h2>Constructor & Destructor Documentation</h2>
40 <a class="anchor" id="aeaac3a412a9015a9378beec9f42d5809"></a><!-- doxytag: member="pp::WebSocket::WebSocket" ref="aeaac3a412a9015a9378beec9f42d5809" args="(const InstanceHandle &instance)" -->
42 <div class="memproto">
43 <table class="memname">
45 <td class="memname"><a class="el" href="classpp_1_1_web_socket.html#aeaac3a412a9015a9378beec9f42d5809">pp::WebSocket::WebSocket</a> </td>
47 <td class="paramtype">const <a class="el" href="classpp_1_1_instance_handle.html">InstanceHandle</a> & </td>
48 <td class="paramname"><em>instance</em></td><td>)</td>
49 <td><code> [explicit]</code></td>
54 <p>Constructs a <a class="el" href="classpp_1_1_web_socket.html" title="The WebSocket class providing bi-directional, full-duplex, communications over a single TCP socket...">WebSocket</a> object. </p>
55 <dl class="params"><dt><b>Parameters:</b></dt><dd>
56 <table class="params">
57 <tr><td class="paramdir">[in]</td><td class="paramname">instance</td><td>The instance with which this resource will be associated. </td></tr>
63 <a class="anchor" id="aa4810e4b945c1fc92493dc206eb35c09"></a><!-- doxytag: member="pp::WebSocket::~WebSocket" ref="aa4810e4b945c1fc92493dc206eb35c09" args="()" -->
65 <div class="memproto">
66 <table class="memname">
68 <td class="memname">virtual <a class="el" href="classpp_1_1_web_socket.html#aa4810e4b945c1fc92493dc206eb35c09">pp::WebSocket::~WebSocket</a> </td>
70 <td class="paramname"></td><td>)</td>
71 <td><code> [virtual]</code></td>
76 <p>Destructs a <a class="el" href="classpp_1_1_web_socket.html" title="The WebSocket class providing bi-directional, full-duplex, communications over a single TCP socket...">WebSocket</a> object. </p>
79 <hr /><h2>Member Function Documentation</h2>
80 <a class="anchor" id="ae7913ea4019cc2a10c9a0390c5959071"></a><!-- doxytag: member="pp::WebSocket::Close" ref="ae7913ea4019cc2a10c9a0390c5959071" args="(uint16_t code, const Var &reason, const CompletionCallback &callback)" -->
82 <div class="memproto">
83 <table class="memname">
85 <td class="memname">int32_t <a class="el" href="classpp_1_1_web_socket.html#ae7913ea4019cc2a10c9a0390c5959071">pp::WebSocket::Close</a> </td>
87 <td class="paramtype">uint16_t </td>
88 <td class="paramname"><em>code</em>, </td>
91 <td class="paramkey"></td>
93 <td class="paramtype">const <a class="el" href="classpp_1_1_var.html">Var</a> & </td>
94 <td class="paramname"><em>reason</em>, </td>
97 <td class="paramkey"></td>
99 <td class="paramtype">const <a class="el" href="classpp_1_1_completion_callback.html">CompletionCallback</a> & </td>
100 <td class="paramname"><em>callback</em> </td>
110 <p><a class="el" href="classpp_1_1_web_socket.html#ae7913ea4019cc2a10c9a0390c5959071" title="Close() closes the specified WebSocket connection by specifying code and reason.">Close()</a> closes the specified <a class="el" href="classpp_1_1_web_socket.html" title="The WebSocket class providing bi-directional, full-duplex, communications over a single TCP socket...">WebSocket</a> connection by specifying <code>code</code> and <code>reason</code>. </p>
111 <dl class="params"><dt><b>Parameters:</b></dt><dd>
112 <table class="params">
113 <tr><td class="paramdir">[in]</td><td class="paramname">code</td><td>The <a class="el" href="classpp_1_1_web_socket.html" title="The WebSocket class providing bi-directional, full-duplex, communications over a single TCP socket...">WebSocket</a> close code. This is ignored if it is 0. <code>PP_WEBSOCKETSTATUSCODE_NORMAL_CLOSURE</code> must be used for the usual case. To indicate some specific error cases, codes in the range <code>PP_WEBSOCKETSTATUSCODE_USER_REGISTERED_MIN</code> to <code>PP_WEBSOCKETSTATUSCODE_USER_REGISTERED_MAX</code>, and in the range <code>PP_WEBSOCKETSTATUSCODE_USER_PRIVATE_MIN</code> to <code>PP_WEBSOCKETSTATUSCODE_USER_PRIVATE_MAX</code> are available.</td></tr>
114 <tr><td class="paramdir">[in]</td><td class="paramname">reason</td><td>A <code><a class="el" href="classpp_1_1_var.html" title="A generic type used for passing data types between the module and the page.">Var</a></code> of string type representing the close reason. This is ignored if it is an undefined type.</td></tr>
115 <tr><td class="paramdir">[in]</td><td class="paramname">callback</td><td>A <code><a class="el" href="classpp_1_1_completion_callback.html" title="This API enables you to implement and receive callbacks when Pepper operations complete asynchronousl...">CompletionCallback</a></code> called when the connection is closed or an error occurs in closing the connection.</td></tr>
119 <dl class="return"><dt><b>Returns:</b></dt><dd>An int32_t containing an error code from <code>pp_errors.h</code>. Returns <code>PP_ERROR_BADARGUMENT</code> if <code>reason</code> contains an invalid character as a UTF-8 string, or is longer than 123 bytes. <code>PP_ERROR_BADARGUMENT</code> corresponds to a JavaScript SyntaxError in the <a class="el" href="classpp_1_1_web_socket.html" title="The WebSocket class providing bi-directional, full-duplex, communications over a single TCP socket...">WebSocket</a> API specification. Returns <code>PP_ERROR_NOACCESS</code> if the code is not an integer equal to 1000 or in the range 3000 to 4999. <code>PP_ERROR_NOACCESS</code> corresponds to an InvalidAccessError in the <a class="el" href="classpp_1_1_web_socket.html" title="The WebSocket class providing bi-directional, full-duplex, communications over a single TCP socket...">WebSocket</a> API specification. Returns <code>PP_ERROR_INPROGRESS</code> if a previous call to <a class="el" href="classpp_1_1_web_socket.html#ae7913ea4019cc2a10c9a0390c5959071" title="Close() closes the specified WebSocket connection by specifying code and reason.">Close()</a> is not finished. </dd></dl>
122 <a class="anchor" id="ad8471399bfca7df23b87ded733d53141"></a><!-- doxytag: member="pp::WebSocket::Connect" ref="ad8471399bfca7df23b87ded733d53141" args="(const Var &url, const Var protocols[], uint32_t protocol_count, const CompletionCallback &callback)" -->
123 <div class="memitem">
124 <div class="memproto">
125 <table class="memname">
127 <td class="memname">int32_t <a class="el" href="classpp_1_1_web_socket.html#ad8471399bfca7df23b87ded733d53141">pp::WebSocket::Connect</a> </td>
129 <td class="paramtype">const <a class="el" href="classpp_1_1_var.html">Var</a> & </td>
130 <td class="paramname"><em>url</em>, </td>
133 <td class="paramkey"></td>
135 <td class="paramtype">const <a class="el" href="classpp_1_1_var.html">Var</a> </td>
136 <td class="paramname"><em>protocols</em>[], </td>
139 <td class="paramkey"></td>
141 <td class="paramtype">uint32_t </td>
142 <td class="paramname"><em>protocol_count</em>, </td>
145 <td class="paramkey"></td>
147 <td class="paramtype">const <a class="el" href="classpp_1_1_completion_callback.html">CompletionCallback</a> & </td>
148 <td class="paramname"><em>callback</em> </td>
158 <p><a class="el" href="classpp_1_1_web_socket.html#ad8471399bfca7df23b87ded733d53141" title="Connect() connects to the specified WebSocket server.">Connect()</a> connects to the specified <a class="el" href="classpp_1_1_web_socket.html" title="The WebSocket class providing bi-directional, full-duplex, communications over a single TCP socket...">WebSocket</a> server. </p>
159 <p>You can call this function once for an object.</p>
160 <dl class="params"><dt><b>Parameters:</b></dt><dd>
161 <table class="params">
162 <tr><td class="paramdir">[in]</td><td class="paramname">url</td><td>A <code><a class="el" href="classpp_1_1_var.html" title="A generic type used for passing data types between the module and the page.">Var</a></code> of string type representing a <a class="el" href="classpp_1_1_web_socket.html" title="The WebSocket class providing bi-directional, full-duplex, communications over a single TCP socket...">WebSocket</a> server URL.</td></tr>
163 <tr><td class="paramdir">[in]</td><td class="paramname">protocols</td><td>A pointer to an array of <code><a class="el" href="classpp_1_1_var.html" title="A generic type used for passing data types between the module and the page.">Var</a></code> of string type specifying sub-protocols. Each <code><a class="el" href="classpp_1_1_var.html" title="A generic type used for passing data types between the module and the page.">Var</a></code> represents one sub-protocol. This argument can be null only if <code>protocol_count</code> is 0.</td></tr>
164 <tr><td class="paramdir">[in]</td><td class="paramname">protocol_count</td><td>The number of sub-protocols in <code>protocols</code>.</td></tr>
165 <tr><td class="paramdir">[in]</td><td class="paramname">callback</td><td>A <code><a class="el" href="classpp_1_1_completion_callback.html" title="This API enables you to implement and receive callbacks when Pepper operations complete asynchronousl...">CompletionCallback</a></code> called when a connection is established or an error occurs in establishing connection.</td></tr>
169 <dl class="return"><dt><b>Returns:</b></dt><dd>An int32_t containing an error code from <code>pp_errors.h</code>. Returns <code>PP_ERROR_BADARGUMENT</code> if specified <code>url</code>, or <code>protocols</code> contains invalid string as defined in the <a class="el" href="classpp_1_1_web_socket.html" title="The WebSocket class providing bi-directional, full-duplex, communications over a single TCP socket...">WebSocket</a> API specification. <code>PP_ERROR_BADARGUMENT</code> corresponds to a SyntaxError in the <a class="el" href="classpp_1_1_web_socket.html" title="The WebSocket class providing bi-directional, full-duplex, communications over a single TCP socket...">WebSocket</a> API specification. Returns <code>PP_ERROR_NOACCESS</code> if the protocol specified in the <code>url</code> is not a secure protocol, but the origin of the caller has a secure scheme. Also returns <code>PP_ERROR_NOACCESS</code> if the port specified in the <code>url</code> is a port that the user agent is configured to block access to because it is a well-known port like SMTP. <code>PP_ERROR_NOACCESS</code> corresponds to a SecurityError of the specification. Returns <code>PP_ERROR_INPROGRESS</code> if this is not the first call to <a class="el" href="classpp_1_1_web_socket.html#ad8471399bfca7df23b87ded733d53141" title="Connect() connects to the specified WebSocket server.">Connect()</a>. </dd></dl>
172 <a class="anchor" id="aee920e33ef266c51ffdaeba8d6924e19"></a><!-- doxytag: member="pp::WebSocket::GetBufferedAmount" ref="aee920e33ef266c51ffdaeba8d6924e19" args="()" -->
173 <div class="memitem">
174 <div class="memproto">
175 <table class="memname">
177 <td class="memname">uint64_t <a class="el" href="classpp_1_1_web_socket.html#aee920e33ef266c51ffdaeba8d6924e19">pp::WebSocket::GetBufferedAmount</a> </td>
179 <td class="paramname"></td><td>)</td>
185 <p><a class="el" href="classpp_1_1_web_socket.html#aee920e33ef266c51ffdaeba8d6924e19" title="GetBufferedAmount() returns the number of bytes of text and binary messages that have been queued for...">GetBufferedAmount()</a> returns the number of bytes of text and binary messages that have been queued for the <a class="el" href="classpp_1_1_web_socket.html" title="The WebSocket class providing bi-directional, full-duplex, communications over a single TCP socket...">WebSocket</a> connection to send, but have not been transmitted to the network yet. </p>
186 <dl class="return"><dt><b>Returns:</b></dt><dd>Returns the number of bytes. </dd></dl>
189 <a class="anchor" id="ab1bb565b7800fd3c147177e4e3a3466f"></a><!-- doxytag: member="pp::WebSocket::GetCloseCode" ref="ab1bb565b7800fd3c147177e4e3a3466f" args="()" -->
190 <div class="memitem">
191 <div class="memproto">
192 <table class="memname">
194 <td class="memname">uint16_t <a class="el" href="classpp_1_1_web_socket.html#ab1bb565b7800fd3c147177e4e3a3466f">pp::WebSocket::GetCloseCode</a> </td>
196 <td class="paramname"></td><td>)</td>
202 <p><a class="el" href="classpp_1_1_web_socket.html#ab1bb565b7800fd3c147177e4e3a3466f" title="GetCloseCode() returns the connection close code for the WebSocket connection.">GetCloseCode()</a> returns the connection close code for the <a class="el" href="classpp_1_1_web_socket.html" title="The WebSocket class providing bi-directional, full-duplex, communications over a single TCP socket...">WebSocket</a> connection. </p>
203 <dl class="return"><dt><b>Returns:</b></dt><dd>Returns 0 if called before the close code is set. </dd></dl>
206 <a class="anchor" id="a27c9cf6d130706fcc5e6fe2f9ed51a7b"></a><!-- doxytag: member="pp::WebSocket::GetCloseReason" ref="a27c9cf6d130706fcc5e6fe2f9ed51a7b" args="()" -->
207 <div class="memitem">
208 <div class="memproto">
209 <table class="memname">
211 <td class="memname"><a class="el" href="classpp_1_1_var.html">Var</a> <a class="el" href="classpp_1_1_web_socket.html#a27c9cf6d130706fcc5e6fe2f9ed51a7b">pp::WebSocket::GetCloseReason</a> </td>
213 <td class="paramname"></td><td>)</td>
219 <p><a class="el" href="classpp_1_1_web_socket.html#a27c9cf6d130706fcc5e6fe2f9ed51a7b" title="GetCloseReason() returns the connection close reason for the WebSocket connection.">GetCloseReason()</a> returns the connection close reason for the <a class="el" href="classpp_1_1_web_socket.html" title="The WebSocket class providing bi-directional, full-duplex, communications over a single TCP socket...">WebSocket</a> connection. </p>
220 <dl class="return"><dt><b>Returns:</b></dt><dd>Returns a <code><a class="el" href="classpp_1_1_var.html" title="A generic type used for passing data types between the module and the page.">Var</a></code> of string type. If called before the close reason is set, the return value contains an empty string. Returns a <code>PP_VARTYPE_UNDEFINED</code> if called on an invalid resource. </dd></dl>
223 <a class="anchor" id="a092b63f716b3e02fc8ec0696ac58df84"></a><!-- doxytag: member="pp::WebSocket::GetCloseWasClean" ref="a092b63f716b3e02fc8ec0696ac58df84" args="()" -->
224 <div class="memitem">
225 <div class="memproto">
226 <table class="memname">
228 <td class="memname">bool <a class="el" href="classpp_1_1_web_socket.html#a092b63f716b3e02fc8ec0696ac58df84">pp::WebSocket::GetCloseWasClean</a> </td>
230 <td class="paramname"></td><td>)</td>
236 <p><a class="el" href="classpp_1_1_web_socket.html#a092b63f716b3e02fc8ec0696ac58df84" title="GetCloseWasClean() returns if the connection was closed cleanly for the specified WebSocket connectio...">GetCloseWasClean()</a> returns if the connection was closed cleanly for the specified <a class="el" href="classpp_1_1_web_socket.html" title="The WebSocket class providing bi-directional, full-duplex, communications over a single TCP socket...">WebSocket</a> connection. </p>
237 <dl class="return"><dt><b>Returns:</b></dt><dd>Returns <code>false</code> if called before the connection is closed, called on an invalid resource, or closed for abnormal reasons. Otherwise, returns <code>true</code> if the connection was closed cleanly. </dd></dl>
240 <a class="anchor" id="ab22093b22b7ceea6957047e1cb5967d2"></a><!-- doxytag: member="pp::WebSocket::GetExtensions" ref="ab22093b22b7ceea6957047e1cb5967d2" args="()" -->
241 <div class="memitem">
242 <div class="memproto">
243 <table class="memname">
245 <td class="memname"><a class="el" href="classpp_1_1_var.html">Var</a> <a class="el" href="classpp_1_1_web_socket.html#ab22093b22b7ceea6957047e1cb5967d2">pp::WebSocket::GetExtensions</a> </td>
247 <td class="paramname"></td><td>)</td>
253 <p><a class="el" href="classpp_1_1_web_socket.html#ab22093b22b7ceea6957047e1cb5967d2" title="GetExtensions() returns the extensions selected by the server for the specified WebSocket connection...">GetExtensions()</a> returns the extensions selected by the server for the specified <a class="el" href="classpp_1_1_web_socket.html" title="The WebSocket class providing bi-directional, full-duplex, communications over a single TCP socket...">WebSocket</a> connection. </p>
254 <dl class="return"><dt><b>Returns:</b></dt><dd>Returns a <code><a class="el" href="classpp_1_1_var.html" title="A generic type used for passing data types between the module and the page.">Var</a></code> of string type. If called before the connection is established, the <code><a class="el" href="classpp_1_1_var.html" title="A generic type used for passing data types between the module and the page.">Var</a></code>'s data is an empty string. Returns a <code>PP_VARTYPE_UNDEFINED</code> if called on an invalid resource. Currently the <code><a class="el" href="classpp_1_1_var.html" title="A generic type used for passing data types between the module and the page.">Var</a></code>'s data for valid resources are always an empty string. </dd></dl>
257 <a class="anchor" id="a1c4b81bb05d30fdef67a07ac904abf0f"></a><!-- doxytag: member="pp::WebSocket::GetProtocol" ref="a1c4b81bb05d30fdef67a07ac904abf0f" args="()" -->
258 <div class="memitem">
259 <div class="memproto">
260 <table class="memname">
262 <td class="memname"><a class="el" href="classpp_1_1_var.html">Var</a> <a class="el" href="classpp_1_1_web_socket.html#a1c4b81bb05d30fdef67a07ac904abf0f">pp::WebSocket::GetProtocol</a> </td>
264 <td class="paramname"></td><td>)</td>
270 <p><a class="el" href="classpp_1_1_web_socket.html#a1c4b81bb05d30fdef67a07ac904abf0f" title="GetProtocol() returns the sub-protocol chosen by the server for the specified WebSocket connection...">GetProtocol()</a> returns the sub-protocol chosen by the server for the specified <a class="el" href="classpp_1_1_web_socket.html" title="The WebSocket class providing bi-directional, full-duplex, communications over a single TCP socket...">WebSocket</a> connection. </p>
271 <dl class="return"><dt><b>Returns:</b></dt><dd>Returns a <code><a class="el" href="classpp_1_1_var.html" title="A generic type used for passing data types between the module and the page.">Var</a></code> of string type. If called before the connection is established, the <code><a class="el" href="classpp_1_1_var.html" title="A generic type used for passing data types between the module and the page.">Var</a></code> contains the empty string. Returns a code>PP_VARTYPE_UNDEFINED if called on an invalid resource. </dd></dl>
274 <a class="anchor" id="afa09ce5acb5f7f168f17b8b3f5939317"></a><!-- doxytag: member="pp::WebSocket::GetReadyState" ref="afa09ce5acb5f7f168f17b8b3f5939317" args="()" -->
275 <div class="memitem">
276 <div class="memproto">
277 <table class="memname">
279 <td class="memname">PP_WebSocketReadyState <a class="el" href="classpp_1_1_web_socket.html#afa09ce5acb5f7f168f17b8b3f5939317">pp::WebSocket::GetReadyState</a> </td>
281 <td class="paramname"></td><td>)</td>
287 <p><a class="el" href="classpp_1_1_web_socket.html#afa09ce5acb5f7f168f17b8b3f5939317" title="GetReadyState() returns the ready state of the specified WebSocket connection.">GetReadyState()</a> returns the ready state of the specified <a class="el" href="classpp_1_1_web_socket.html" title="The WebSocket class providing bi-directional, full-duplex, communications over a single TCP socket...">WebSocket</a> connection. </p>
288 <dl class="return"><dt><b>Returns:</b></dt><dd>Returns <code>PP_WEBSOCKETREADYSTATE_INVALID</code> if called before <a class="el" href="classpp_1_1_web_socket.html#ad8471399bfca7df23b87ded733d53141" title="Connect() connects to the specified WebSocket server.">Connect()</a> is called, or if this function is called on an invalid resource. </dd></dl>
291 <a class="anchor" id="ab76ccebfe20facff03464e71f4af7719"></a><!-- doxytag: member="pp::WebSocket::GetURL" ref="ab76ccebfe20facff03464e71f4af7719" args="()" -->
292 <div class="memitem">
293 <div class="memproto">
294 <table class="memname">
296 <td class="memname"><a class="el" href="classpp_1_1_var.html">Var</a> <a class="el" href="classpp_1_1_web_socket.html#ab76ccebfe20facff03464e71f4af7719">pp::WebSocket::GetURL</a> </td>
298 <td class="paramname"></td><td>)</td>
304 <p><a class="el" href="classpp_1_1_web_socket.html#ab76ccebfe20facff03464e71f4af7719" title="GetURL() returns the URL associated with specified WebSocket connection.">GetURL()</a> returns the URL associated with specified <a class="el" href="classpp_1_1_web_socket.html" title="The WebSocket class providing bi-directional, full-duplex, communications over a single TCP socket...">WebSocket</a> connection. </p>
305 <dl class="return"><dt><b>Returns:</b></dt><dd>Returns a <code><a class="el" href="classpp_1_1_var.html" title="A generic type used for passing data types between the module and the page.">Var</a></code> of string type. If called before the connection is established, the <code><a class="el" href="classpp_1_1_var.html" title="A generic type used for passing data types between the module and the page.">Var</a></code> contains the empty string. Returns a <code>PP_VARTYPE_UNDEFINED</code> if this function is called on an invalid resource. </dd></dl>
308 <a class="anchor" id="a1eb972115700589ebf6998db4f411c56"></a><!-- doxytag: member="pp::WebSocket::ReceiveMessage" ref="a1eb972115700589ebf6998db4f411c56" args="(Var *message, const CompletionCallback &callback)" -->
309 <div class="memitem">
310 <div class="memproto">
311 <table class="memname">
313 <td class="memname">int32_t <a class="el" href="classpp_1_1_web_socket.html#a1eb972115700589ebf6998db4f411c56">pp::WebSocket::ReceiveMessage</a> </td>
315 <td class="paramtype"><a class="el" href="classpp_1_1_var.html">Var</a> * </td>
316 <td class="paramname"><em>message</em>, </td>
319 <td class="paramkey"></td>
321 <td class="paramtype">const <a class="el" href="classpp_1_1_completion_callback.html">CompletionCallback</a> & </td>
322 <td class="paramname"><em>callback</em> </td>
332 <p><a class="el" href="classpp_1_1_web_socket.html#a1eb972115700589ebf6998db4f411c56" title="ReceiveMessage() receives a message from the WebSocket server.">ReceiveMessage()</a> receives a message from the <a class="el" href="classpp_1_1_web_socket.html" title="The WebSocket class providing bi-directional, full-duplex, communications over a single TCP socket...">WebSocket</a> server. </p>
333 <p>This interface only returns a single message. That is, this interface must be called at least N times to receive N messages, no matter the size of each message.</p>
334 <dl class="params"><dt><b>Parameters:</b></dt><dd>
335 <table class="params">
336 <tr><td class="paramdir">[out]</td><td class="paramname">message</td><td>The received message is copied to provided <code>message</code>. The <code>message</code> must remain valid until <a class="el" href="classpp_1_1_web_socket.html#a1eb972115700589ebf6998db4f411c56" title="ReceiveMessage() receives a message from the WebSocket server.">ReceiveMessage()</a> completes. Its received <code><a class="el" href="classpp_1_1_var.html" title="A generic type used for passing data types between the module and the page.">Var</a></code> will be of string or ArrayBuffer type.</td></tr>
337 <tr><td class="paramdir">[in]</td><td class="paramname">callback</td><td>A <code><a class="el" href="classpp_1_1_completion_callback.html" title="This API enables you to implement and receive callbacks when Pepper operations complete asynchronousl...">CompletionCallback</a></code> called when <a class="el" href="classpp_1_1_web_socket.html#a1eb972115700589ebf6998db4f411c56" title="ReceiveMessage() receives a message from the WebSocket server.">ReceiveMessage()</a> completes. This callback is ignored if <a class="el" href="classpp_1_1_web_socket.html#a1eb972115700589ebf6998db4f411c56" title="ReceiveMessage() receives a message from the WebSocket server.">ReceiveMessage()</a> completes synchronously and returns <code>PP_OK</code>.</td></tr>
341 <dl class="return"><dt><b>Returns:</b></dt><dd>An int32_t containing an error code from <code>pp_errors.h</code>. If an error is detected or connection is closed, <a class="el" href="classpp_1_1_web_socket.html#a1eb972115700589ebf6998db4f411c56" title="ReceiveMessage() receives a message from the WebSocket server.">ReceiveMessage()</a> returns <code>PP_ERROR_FAILED</code> after all buffered messages are received. Until buffered message become empty, <a class="el" href="classpp_1_1_web_socket.html#a1eb972115700589ebf6998db4f411c56" title="ReceiveMessage() receives a message from the WebSocket server.">ReceiveMessage()</a> continues to return <code>PP_OK</code> as if connection is still established without errors. </dd></dl>
344 <a class="anchor" id="a276b1aae76ba9d899475aaf9c2cd4f28"></a><!-- doxytag: member="pp::WebSocket::SendMessage" ref="a276b1aae76ba9d899475aaf9c2cd4f28" args="(const Var &message)" -->
345 <div class="memitem">
346 <div class="memproto">
347 <table class="memname">
349 <td class="memname">int32_t <a class="el" href="classpp_1_1_web_socket.html#a276b1aae76ba9d899475aaf9c2cd4f28">pp::WebSocket::SendMessage</a> </td>
351 <td class="paramtype">const <a class="el" href="classpp_1_1_var.html">Var</a> & </td>
352 <td class="paramname"><em>message</em></td><td>)</td>
358 <p><a class="el" href="classpp_1_1_web_socket.html#a276b1aae76ba9d899475aaf9c2cd4f28" title="SendMessage() sends a message to the WebSocket server.">SendMessage()</a> sends a message to the <a class="el" href="classpp_1_1_web_socket.html" title="The WebSocket class providing bi-directional, full-duplex, communications over a single TCP socket...">WebSocket</a> server. </p>
359 <dl class="params"><dt><b>Parameters:</b></dt><dd>
360 <table class="params">
361 <tr><td class="paramdir">[in]</td><td class="paramname">message</td><td>A message to send. The message is copied to an internal buffer, so the caller can free <code>message</code> safely after returning from the function. This <code><a class="el" href="classpp_1_1_var.html" title="A generic type used for passing data types between the module and the page.">Var</a></code> must be of string or ArrayBuffer types.</td></tr>
365 <dl class="return"><dt><b>Returns:</b></dt><dd>An int32_t containing an error code from <code>pp_errors.h</code>. Returns <code>PP_ERROR_FAILED</code> if the ReadyState is <code>PP_WEBSOCKETREADYSTATE_CONNECTING</code>. <code>PP_ERROR_FAILED</code> corresponds to a JavaScript InvalidStateError in the <a class="el" href="classpp_1_1_web_socket.html" title="The WebSocket class providing bi-directional, full-duplex, communications over a single TCP socket...">WebSocket</a> API specification. Returns <code>PP_ERROR_BADARGUMENT</code> if the provided <code>message</code> contains an invalid character as a UTF-8 string. <code>PP_ERROR_BADARGUMENT</code> corresponds to a JavaScript SyntaxError in the <a class="el" href="classpp_1_1_web_socket.html" title="The WebSocket class providing bi-directional, full-duplex, communications over a single TCP socket...">WebSocket</a> API specification. Otherwise, returns <code>PP_OK</code>, but it doesn't necessarily mean that the server received the message. </dd></dl>
368 <hr />The documentation for this class was generated from the following file:<ul>
369 <li><a class="el" href="websocket_8h.html">websocket.h</a></li>
371 </div><!-- contents -->
372 {{/partials.standard_nacl_article}}