chromium/native_client_sdk/doc_generated/pepper_stable/cpp/classpp_1_1_web_socket.html

{{+bindTo:partials.standard_nacl_api}}
<h1>pp::WebSocket Class Reference</h1>
<div id="doxygen-ref">
{{- dummy div to appease doxygen -}}
  <div>
<!-- Generated by Doxygen 1.7.6.1 -->



</div>
<!--header-->
<div class="contents">
<!-- doxytag: class="pp::WebSocket" --><!-- doxytag: inherits="pp::Resource" --><div class="dynheader">
Inheritance diagram for pp::WebSocket:</div>
<div class="dyncontent">
<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>
<map name="pp_1_1_web_socket_inherit__map" id="pp_1_1_web_socket_inherit__map">
<area shape="rect" id="node2" href="classpp_1_1_resource.html" title="A reference counted module resource." alt="" coords="11,5,115,32"></area></map>
<center><span class="legend">[<a href="graph_legend.html">legend</a>]</span></center></div>
<p><a href="classpp_1_1_web_socket-members.html">List of all members.</a></p>
<h2>
Public Member Functions</h2><table class="memberdecls">

<tr><td class="memItemLeft" align="right" valign="top">&#160;</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> &amp;instance)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classpp_1_1_web_socket.html#aa4810e4b945c1fc92493dc206eb35c09">~WebSocket</a> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int32_t&#160;</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> &amp;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> &amp;callback)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int32_t&#160;</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> &amp;reason, const <a class="el" href="classpp_1_1_completion_callback.html">CompletionCallback</a> &amp;callback)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int32_t&#160;</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> &amp;callback)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int32_t&#160;</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> &amp;message)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">uint64_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classpp_1_1_web_socket.html#aee920e33ef266c51ffdaeba8d6924e19">GetBufferedAmount</a> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">uint16_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classpp_1_1_web_socket.html#ab1bb565b7800fd3c147177e4e3a3466f">GetCloseCode</a> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="classpp_1_1_var.html">Var</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classpp_1_1_web_socket.html#a27c9cf6d130706fcc5e6fe2f9ed51a7b">GetCloseReason</a> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classpp_1_1_web_socket.html#a092b63f716b3e02fc8ec0696ac58df84">GetCloseWasClean</a> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="classpp_1_1_var.html">Var</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classpp_1_1_web_socket.html#ab22093b22b7ceea6957047e1cb5967d2">GetExtensions</a> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="classpp_1_1_var.html">Var</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classpp_1_1_web_socket.html#a1c4b81bb05d30fdef67a07ac904abf0f">GetProtocol</a> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">PP_WebSocketReadyState&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classpp_1_1_web_socket.html#afa09ce5acb5f7f168f17b8b3f5939317">GetReadyState</a> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="classpp_1_1_var.html">Var</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classpp_1_1_web_socket.html#ab76ccebfe20facff03464e71f4af7719">GetURL</a> ()</td></tr>
</table>
<hr /><a name="details" id="details"></a><h2>Detailed Description</h2>
<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>
</div><hr /><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" id="aeaac3a412a9015a9378beec9f42d5809"></a><!-- doxytag: member="pp::WebSocket::WebSocket" ref="aeaac3a412a9015a9378beec9f42d5809" args="(const InstanceHandle &amp;instance)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="classpp_1_1_web_socket.html#aeaac3a412a9015a9378beec9f42d5809">pp::WebSocket::WebSocket</a> </td>
<td>(</td>
<td class="paramtype">const <a class="el" href="classpp_1_1_instance_handle.html">InstanceHandle</a> &amp;&#160;</td>
<td class="paramname"><em>instance</em></td><td>)</td>
<td><code> [explicit]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<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>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">instance</td><td>The instance with which this resource will be associated. </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a class="anchor" id="aa4810e4b945c1fc92493dc206eb35c09"></a><!-- doxytag: member="pp::WebSocket::~WebSocket" ref="aa4810e4b945c1fc92493dc206eb35c09" args="()" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">virtual <a class="el" href="classpp_1_1_web_socket.html#aa4810e4b945c1fc92493dc206eb35c09">pp::WebSocket::~WebSocket</a> </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td><code> [virtual]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<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>
</div>
</div>
<hr /><h2>Member Function Documentation</h2>
<a class="anchor" id="ae7913ea4019cc2a10c9a0390c5959071"></a><!-- doxytag: member="pp::WebSocket::Close" ref="ae7913ea4019cc2a10c9a0390c5959071" args="(uint16_t code, const Var &amp;reason, const CompletionCallback &amp;callback)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int32_t <a class="el" href="classpp_1_1_web_socket.html#ae7913ea4019cc2a10c9a0390c5959071">pp::WebSocket::Close</a> </td>
<td>(</td>
<td class="paramtype">uint16_t&#160;</td>
<td class="paramname"><em>code</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const <a class="el" href="classpp_1_1_var.html">Var</a> &amp;&#160;</td>
<td class="paramname"><em>reason</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const <a class="el" href="classpp_1_1_completion_callback.html">CompletionCallback</a> &amp;&#160;</td>
<td class="paramname"><em>callback</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<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>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
<table class="params">
<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>
<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>
<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>
</table>
</dd>
</dl>
<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>
</div>
</div>
<a class="anchor" id="ad8471399bfca7df23b87ded733d53141"></a><!-- doxytag: member="pp::WebSocket::Connect" ref="ad8471399bfca7df23b87ded733d53141" args="(const Var &amp;url, const Var protocols[], uint32_t protocol_count, const CompletionCallback &amp;callback)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int32_t <a class="el" href="classpp_1_1_web_socket.html#ad8471399bfca7df23b87ded733d53141">pp::WebSocket::Connect</a> </td>
<td>(</td>
<td class="paramtype">const <a class="el" href="classpp_1_1_var.html">Var</a> &amp;&#160;</td>
<td class="paramname"><em>url</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const <a class="el" href="classpp_1_1_var.html">Var</a>&#160;</td>
<td class="paramname"><em>protocols</em>[], </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint32_t&#160;</td>
<td class="paramname"><em>protocol_count</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const <a class="el" href="classpp_1_1_completion_callback.html">CompletionCallback</a> &amp;&#160;</td>
<td class="paramname"><em>callback</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<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>
<p>You can call this function once for an object.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
<table class="params">
<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>
<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>
<tr><td class="paramdir">[in]</td><td class="paramname">protocol_count</td><td>The number of sub-protocols in <code>protocols</code>.</td></tr>
<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>
</table>
</dd>
</dl>
<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>
</div>
</div>
<a class="anchor" id="aee920e33ef266c51ffdaeba8d6924e19"></a><!-- doxytag: member="pp::WebSocket::GetBufferedAmount" ref="aee920e33ef266c51ffdaeba8d6924e19" args="()" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">uint64_t <a class="el" href="classpp_1_1_web_socket.html#aee920e33ef266c51ffdaeba8d6924e19">pp::WebSocket::GetBufferedAmount</a> </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<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>
<dl class="return"><dt><b>Returns:</b></dt><dd>Returns the number of bytes. </dd></dl>
</div>
</div>
<a class="anchor" id="ab1bb565b7800fd3c147177e4e3a3466f"></a><!-- doxytag: member="pp::WebSocket::GetCloseCode" ref="ab1bb565b7800fd3c147177e4e3a3466f" args="()" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">uint16_t <a class="el" href="classpp_1_1_web_socket.html#ab1bb565b7800fd3c147177e4e3a3466f">pp::WebSocket::GetCloseCode</a> </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<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>
<dl class="return"><dt><b>Returns:</b></dt><dd>Returns 0 if called before the close code is set. </dd></dl>
</div>
</div>
<a class="anchor" id="a27c9cf6d130706fcc5e6fe2f9ed51a7b"></a><!-- doxytag: member="pp::WebSocket::GetCloseReason" ref="a27c9cf6d130706fcc5e6fe2f9ed51a7b" args="()" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<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>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<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>
<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>
</div>
</div>
<a class="anchor" id="a092b63f716b3e02fc8ec0696ac58df84"></a><!-- doxytag: member="pp::WebSocket::GetCloseWasClean" ref="a092b63f716b3e02fc8ec0696ac58df84" args="()" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">bool <a class="el" href="classpp_1_1_web_socket.html#a092b63f716b3e02fc8ec0696ac58df84">pp::WebSocket::GetCloseWasClean</a> </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<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>
<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>
</div>
</div>
<a class="anchor" id="ab22093b22b7ceea6957047e1cb5967d2"></a><!-- doxytag: member="pp::WebSocket::GetExtensions" ref="ab22093b22b7ceea6957047e1cb5967d2" args="()" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<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>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<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>
<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>
</div>
</div>
<a class="anchor" id="a1c4b81bb05d30fdef67a07ac904abf0f"></a><!-- doxytag: member="pp::WebSocket::GetProtocol" ref="a1c4b81bb05d30fdef67a07ac904abf0f" args="()" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<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>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<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>
<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&gt;PP_VARTYPE_UNDEFINED if called on an invalid resource. </dd></dl>
</div>
</div>
<a class="anchor" id="afa09ce5acb5f7f168f17b8b3f5939317"></a><!-- doxytag: member="pp::WebSocket::GetReadyState" ref="afa09ce5acb5f7f168f17b8b3f5939317" args="()" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">PP_WebSocketReadyState <a class="el" href="classpp_1_1_web_socket.html#afa09ce5acb5f7f168f17b8b3f5939317">pp::WebSocket::GetReadyState</a> </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<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>
<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>
</div>
</div>
<a class="anchor" id="ab76ccebfe20facff03464e71f4af7719"></a><!-- doxytag: member="pp::WebSocket::GetURL" ref="ab76ccebfe20facff03464e71f4af7719" args="()" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<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>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<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>
<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>
</div>
</div>
<a class="anchor" id="a1eb972115700589ebf6998db4f411c56"></a><!-- doxytag: member="pp::WebSocket::ReceiveMessage" ref="a1eb972115700589ebf6998db4f411c56" args="(Var *message, const CompletionCallback &amp;callback)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int32_t <a class="el" href="classpp_1_1_web_socket.html#a1eb972115700589ebf6998db4f411c56">pp::WebSocket::ReceiveMessage</a> </td>
<td>(</td>
<td class="paramtype"><a class="el" href="classpp_1_1_var.html">Var</a> *&#160;</td>
<td class="paramname"><em>message</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const <a class="el" href="classpp_1_1_completion_callback.html">CompletionCallback</a> &amp;&#160;</td>
<td class="paramname"><em>callback</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<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>
<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>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
<table class="params">
<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>
<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>
</table>
</dd>
</dl>
<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>
</div>
</div>
<a class="anchor" id="a276b1aae76ba9d899475aaf9c2cd4f28"></a><!-- doxytag: member="pp::WebSocket::SendMessage" ref="a276b1aae76ba9d899475aaf9c2cd4f28" args="(const Var &amp;message)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int32_t <a class="el" href="classpp_1_1_web_socket.html#a276b1aae76ba9d899475aaf9c2cd4f28">pp::WebSocket::SendMessage</a> </td>
<td>(</td>
<td class="paramtype">const <a class="el" href="classpp_1_1_var.html">Var</a> &amp;&#160;</td>
<td class="paramname"><em>message</em></td><td>)</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<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>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
<table class="params">
<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>
</table>
</dd>
</dl>
<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>
</div>
</div>
<hr />The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="websocket_8h.html">websocket.h</a></li>
</ul>
</div><!-- contents -->
</div>
{{/partials.standard_nacl_api}}