1 {{+bindTo:partials.standard_nacl_article}}
2 <h1>pp::WebSocket Class Reference</h1>
4 {{- dummy div to appease doxygen -}}
6 <!-- Generated by Doxygen 1.7.6.1 -->
12 <div class="contents">
13 <!-- doxytag: class="pp::WebSocket" --><!-- doxytag: inherits="pp::Resource" --><div class="dynheader">
14 Inheritance diagram for pp::WebSocket:</div>
15 <div class="dyncontent">
16 <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>
17 <map name="pp_1_1_web_socket_inherit__map" id="pp_1_1_web_socket_inherit__map">
18 <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>
19 <center><span class="legend">[<a href="graph_legend.html">legend</a>]</span></center></div>
20 <p><a href="classpp_1_1_web_socket-members.html">List of all members.</a></p>
22 Public Member Functions</h2><table class="memberdecls">
24 <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>
25 <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>
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#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>
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#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>
28 <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>
29 <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>
30 <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>
31 <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>
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#a27c9cf6d130706fcc5e6fe2f9ed51a7b">GetCloseReason</a> ()</td></tr>
33 <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>
34 <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>
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#a1c4b81bb05d30fdef67a07ac904abf0f">GetProtocol</a> ()</td></tr>
36 <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>
37 <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>
39 <hr /><a name="details" id="details"></a><h2>Detailed Description</h2>
40 <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>
41 </div><hr /><h2>Constructor & Destructor Documentation</h2>
42 <a class="anchor" id="aeaac3a412a9015a9378beec9f42d5809"></a><!-- doxytag: member="pp::WebSocket::WebSocket" ref="aeaac3a412a9015a9378beec9f42d5809" args="(const InstanceHandle &instance)" -->
44 <div class="memproto">
45 <table class="memname">
47 <td class="memname"><a class="el" href="classpp_1_1_web_socket.html#aeaac3a412a9015a9378beec9f42d5809">pp::WebSocket::WebSocket</a> </td>
49 <td class="paramtype">const <a class="el" href="classpp_1_1_instance_handle.html">InstanceHandle</a> & </td>
50 <td class="paramname"><em>instance</em></td><td>)</td>
51 <td><code> [explicit]</code></td>
56 <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>
57 <dl class="params"><dt><b>Parameters:</b></dt><dd>
58 <table class="params">
59 <tr><td class="paramdir">[in]</td><td class="paramname">instance</td><td>The instance with which this resource will be associated. </td></tr>
65 <a class="anchor" id="aa4810e4b945c1fc92493dc206eb35c09"></a><!-- doxytag: member="pp::WebSocket::~WebSocket" ref="aa4810e4b945c1fc92493dc206eb35c09" args="()" -->
67 <div class="memproto">
68 <table class="memname">
70 <td class="memname">virtual <a class="el" href="classpp_1_1_web_socket.html#aa4810e4b945c1fc92493dc206eb35c09">pp::WebSocket::~WebSocket</a> </td>
72 <td class="paramname"></td><td>)</td>
73 <td><code> [virtual]</code></td>
78 <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>
81 <hr /><h2>Member Function Documentation</h2>
82 <a class="anchor" id="ae7913ea4019cc2a10c9a0390c5959071"></a><!-- doxytag: member="pp::WebSocket::Close" ref="ae7913ea4019cc2a10c9a0390c5959071" args="(uint16_t code, const Var &reason, const CompletionCallback &callback)" -->
84 <div class="memproto">
85 <table class="memname">
87 <td class="memname">int32_t <a class="el" href="classpp_1_1_web_socket.html#ae7913ea4019cc2a10c9a0390c5959071">pp::WebSocket::Close</a> </td>
89 <td class="paramtype">uint16_t </td>
90 <td class="paramname"><em>code</em>, </td>
93 <td class="paramkey"></td>
95 <td class="paramtype">const <a class="el" href="classpp_1_1_var.html">Var</a> & </td>
96 <td class="paramname"><em>reason</em>, </td>
99 <td class="paramkey"></td>
101 <td class="paramtype">const <a class="el" href="classpp_1_1_completion_callback.html">CompletionCallback</a> & </td>
102 <td class="paramname"><em>callback</em> </td>
112 <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>
113 <dl class="params"><dt><b>Parameters:</b></dt><dd>
114 <table class="params">
115 <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>
116 <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>
117 <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>
121 <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>
124 <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)" -->
125 <div class="memitem">
126 <div class="memproto">
127 <table class="memname">
129 <td class="memname">int32_t <a class="el" href="classpp_1_1_web_socket.html#ad8471399bfca7df23b87ded733d53141">pp::WebSocket::Connect</a> </td>
131 <td class="paramtype">const <a class="el" href="classpp_1_1_var.html">Var</a> & </td>
132 <td class="paramname"><em>url</em>, </td>
135 <td class="paramkey"></td>
137 <td class="paramtype">const <a class="el" href="classpp_1_1_var.html">Var</a> </td>
138 <td class="paramname"><em>protocols</em>[], </td>
141 <td class="paramkey"></td>
143 <td class="paramtype">uint32_t </td>
144 <td class="paramname"><em>protocol_count</em>, </td>
147 <td class="paramkey"></td>
149 <td class="paramtype">const <a class="el" href="classpp_1_1_completion_callback.html">CompletionCallback</a> & </td>
150 <td class="paramname"><em>callback</em> </td>
160 <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>
161 <p>You can call this function once for an object.</p>
162 <dl class="params"><dt><b>Parameters:</b></dt><dd>
163 <table class="params">
164 <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>
165 <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>
166 <tr><td class="paramdir">[in]</td><td class="paramname">protocol_count</td><td>The number of sub-protocols in <code>protocols</code>.</td></tr>
167 <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>
171 <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>
174 <a class="anchor" id="aee920e33ef266c51ffdaeba8d6924e19"></a><!-- doxytag: member="pp::WebSocket::GetBufferedAmount" ref="aee920e33ef266c51ffdaeba8d6924e19" args="()" -->
175 <div class="memitem">
176 <div class="memproto">
177 <table class="memname">
179 <td class="memname">uint64_t <a class="el" href="classpp_1_1_web_socket.html#aee920e33ef266c51ffdaeba8d6924e19">pp::WebSocket::GetBufferedAmount</a> </td>
181 <td class="paramname"></td><td>)</td>
187 <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>
188 <dl class="return"><dt><b>Returns:</b></dt><dd>Returns the number of bytes. </dd></dl>
191 <a class="anchor" id="ab1bb565b7800fd3c147177e4e3a3466f"></a><!-- doxytag: member="pp::WebSocket::GetCloseCode" ref="ab1bb565b7800fd3c147177e4e3a3466f" args="()" -->
192 <div class="memitem">
193 <div class="memproto">
194 <table class="memname">
196 <td class="memname">uint16_t <a class="el" href="classpp_1_1_web_socket.html#ab1bb565b7800fd3c147177e4e3a3466f">pp::WebSocket::GetCloseCode</a> </td>
198 <td class="paramname"></td><td>)</td>
204 <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>
205 <dl class="return"><dt><b>Returns:</b></dt><dd>Returns 0 if called before the close code is set. </dd></dl>
208 <a class="anchor" id="a27c9cf6d130706fcc5e6fe2f9ed51a7b"></a><!-- doxytag: member="pp::WebSocket::GetCloseReason" ref="a27c9cf6d130706fcc5e6fe2f9ed51a7b" args="()" -->
209 <div class="memitem">
210 <div class="memproto">
211 <table class="memname">
213 <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>
215 <td class="paramname"></td><td>)</td>
221 <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>
222 <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>
225 <a class="anchor" id="a092b63f716b3e02fc8ec0696ac58df84"></a><!-- doxytag: member="pp::WebSocket::GetCloseWasClean" ref="a092b63f716b3e02fc8ec0696ac58df84" args="()" -->
226 <div class="memitem">
227 <div class="memproto">
228 <table class="memname">
230 <td class="memname">bool <a class="el" href="classpp_1_1_web_socket.html#a092b63f716b3e02fc8ec0696ac58df84">pp::WebSocket::GetCloseWasClean</a> </td>
232 <td class="paramname"></td><td>)</td>
238 <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>
239 <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>
242 <a class="anchor" id="ab22093b22b7ceea6957047e1cb5967d2"></a><!-- doxytag: member="pp::WebSocket::GetExtensions" ref="ab22093b22b7ceea6957047e1cb5967d2" args="()" -->
243 <div class="memitem">
244 <div class="memproto">
245 <table class="memname">
247 <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>
249 <td class="paramname"></td><td>)</td>
255 <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>
256 <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>
259 <a class="anchor" id="a1c4b81bb05d30fdef67a07ac904abf0f"></a><!-- doxytag: member="pp::WebSocket::GetProtocol" ref="a1c4b81bb05d30fdef67a07ac904abf0f" args="()" -->
260 <div class="memitem">
261 <div class="memproto">
262 <table class="memname">
264 <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>
266 <td class="paramname"></td><td>)</td>
272 <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>
273 <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>
276 <a class="anchor" id="afa09ce5acb5f7f168f17b8b3f5939317"></a><!-- doxytag: member="pp::WebSocket::GetReadyState" ref="afa09ce5acb5f7f168f17b8b3f5939317" args="()" -->
277 <div class="memitem">
278 <div class="memproto">
279 <table class="memname">
281 <td class="memname">PP_WebSocketReadyState <a class="el" href="classpp_1_1_web_socket.html#afa09ce5acb5f7f168f17b8b3f5939317">pp::WebSocket::GetReadyState</a> </td>
283 <td class="paramname"></td><td>)</td>
289 <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>
290 <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>
293 <a class="anchor" id="ab76ccebfe20facff03464e71f4af7719"></a><!-- doxytag: member="pp::WebSocket::GetURL" ref="ab76ccebfe20facff03464e71f4af7719" args="()" -->
294 <div class="memitem">
295 <div class="memproto">
296 <table class="memname">
298 <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>
300 <td class="paramname"></td><td>)</td>
306 <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>
307 <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>
310 <a class="anchor" id="a1eb972115700589ebf6998db4f411c56"></a><!-- doxytag: member="pp::WebSocket::ReceiveMessage" ref="a1eb972115700589ebf6998db4f411c56" args="(Var *message, const CompletionCallback &callback)" -->
311 <div class="memitem">
312 <div class="memproto">
313 <table class="memname">
315 <td class="memname">int32_t <a class="el" href="classpp_1_1_web_socket.html#a1eb972115700589ebf6998db4f411c56">pp::WebSocket::ReceiveMessage</a> </td>
317 <td class="paramtype"><a class="el" href="classpp_1_1_var.html">Var</a> * </td>
318 <td class="paramname"><em>message</em>, </td>
321 <td class="paramkey"></td>
323 <td class="paramtype">const <a class="el" href="classpp_1_1_completion_callback.html">CompletionCallback</a> & </td>
324 <td class="paramname"><em>callback</em> </td>
334 <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>
335 <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>
336 <dl class="params"><dt><b>Parameters:</b></dt><dd>
337 <table class="params">
338 <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>
339 <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>
343 <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>
346 <a class="anchor" id="a276b1aae76ba9d899475aaf9c2cd4f28"></a><!-- doxytag: member="pp::WebSocket::SendMessage" ref="a276b1aae76ba9d899475aaf9c2cd4f28" args="(const Var &message)" -->
347 <div class="memitem">
348 <div class="memproto">
349 <table class="memname">
351 <td class="memname">int32_t <a class="el" href="classpp_1_1_web_socket.html#a276b1aae76ba9d899475aaf9c2cd4f28">pp::WebSocket::SendMessage</a> </td>
353 <td class="paramtype">const <a class="el" href="classpp_1_1_var.html">Var</a> & </td>
354 <td class="paramname"><em>message</em></td><td>)</td>
360 <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>
361 <dl class="params"><dt><b>Parameters:</b></dt><dd>
362 <table class="params">
363 <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>
367 <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>
370 <hr />The documentation for this class was generated from the following file:<ul>
371 <li><a class="el" href="websocket_8h.html">websocket.h</a></li>
373 </div><!-- contents -->
375 {{/partials.standard_nacl_article}}