enet/_web_socket_8hpp_source.html

171 lines
33 KiB
HTML

<!-- HTML header for doxygen 1.8.8-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- For Mobile Devices -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta name="generator" content="Doxygen 1.8.12"/>
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<title>enet: Ewol network abstraction: framework/atria-soft/enet/enet/WebSocket.hpp Source File</title>
<!--<link href="tabs.css" rel="stylesheet" type="text/css"/>-->
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="customdoxygen.css" rel="stylesheet" type="text/css"/>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
<script type="text/javascript" src="doxy-boot.js"></script>
</head>
<body>
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand">enet: Ewol network abstraction 0.4.0</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a href="index.html">Main&nbsp;Page</a></li>
<li><a href="pages.html">Related&nbsp;Pages</a></li>
<li><a href="namespaces.html">Namespaces</a></li>
<li><a href="annotated.html">Classes</a></li>
<li><a href="files.html">Files</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
Link-libs<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><a href="http://HeeroYui.github.io/lutin">lutin</a></li>
<li><a href="http://atria-soft.github.io/ewol">ewol</a></li>
<li><a href="http://atria-soft.github.io/echrono">echrono</a></li>
<li><a href="http://atria-soft.github.io/etk">etk</a></li>
<li><a href="http://atria-soft.github.io/ejson">ejson</a></li>
<li><a href="http://atria-soft.github.io/exml">exml</a></li>
<li><a href="http://atria-soft.github.io/esvg">esvg</a></li>
<li><a href="http://atria-soft.github.io/egami">egami</a></li>
<li><a href="http://atria-soft.github.io/gale">gale</a></li>
<li><a href="http://atria-soft.github.io/ege">ege</a></li>
<li><a href="http://atria-soft.github.io/elog">elog</a></li>
<li><a href="http://atria-soft.github.io/ememory">ememory</a></li>
<li><a href="http://atria-soft.github.io/enet">enet</a></li>
<li><a href="http://atria-soft.github.io/eproperty">eproperty</a></li>
<li><a href="http://atria-soft.github.io/esignal">esignal</a></li>
<li><a href="http://atria-soft.github.io/etranslate">etranslate</a></li>
<li><a href="http://atria-soft.github.io/zeus">zeus</a></li>
<li><a href="http://musicdsp.github.io/audio-ess">audio-ess</a></li>
<li><a href="http://musicdsp.github.io/audio">audio</a></li>
<li><a href="http://musicdsp.github.io/audio-drain">audio-drain</a></li>
<li><a href="http://musicdsp.github.io/audio-orchestra">audio-orchestra</a></li>
<li><a href="http://musicdsp.github.io/audio-river">audio-river</a></li>
</ul>
</li>
</ul>
<div id="search-box" class="input-group">
<div class="input-group-btn">
<button aria-expanded="false" type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<span class="glyphicon glyphicon-search"></span>
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li><a href="#">All</a></li>
<li><a href="#">Classes</a></li>
<li><a href="#">Namespaces</a></li>
<li><a href="#">Files</a></li>
<li><a href="#">Functions</a></li>
<li><a href="#">Variables</a></li>
<li><a href="#">Typedefs</a></li>
<li><a href="#">Enumerations</a></li>
<li><a href="#">Enumerator</a></li>
<li><a href="#">Friends</a></li>
<li><a href="#">Macros</a></li>
<li><a href="#">Pages</a></li>
</ul>
</div>
<button id="search-close" type="button" class="close" aria-label="Close">
<span aria-hidden="true"></span>
</button>
<input id="search-field" class="form-control" accesskey="S" onkeydown="searchBox.OnSearchFieldChange(event);" placeholder="Search ..." type="text">
</div>
</div><!--/.nav-collapse -->
</div>
</nav>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div class="content" id="content">
<div class="container">
<div class="row">
<div class="col-sm-12 panel panel-default" style="padding-bottom: 15px;">
<div style="margin-bottom: 15px;margin-top: 60px;">
<!-- end header part -->
<!-- Generated by Doxygen 1.8.12 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="dir_644e041c3a6521da7b27eba0e4eb2b95.html">framework</a></li><li class="navelem"><a class="el" href="dir_a094892b17be858f66bf3446bbb755c7.html">atria-soft</a></li><li class="navelem"><a class="el" href="dir_f7835a0040178a7c3fe3e7c27f6d9084.html">enet</a></li><li class="navelem"><a class="el" href="dir_8df4c94f510f53f1374a2c2b5801aba9.html">enet</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="headertitle">
<div class="title">WebSocket.hpp</div> </div>
</div><!--header-->
<div class="contents">
<a href="_web_socket_8hpp.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span>&#160;</div><div class="line"><a name="l00006"></a><span class="lineno"> 6</span>&#160;<span class="preprocessor">#pragma once</span></div><div class="line"><a name="l00007"></a><span class="lineno"> 7</span>&#160;</div><div class="line"><a name="l00008"></a><span class="lineno"> 8</span>&#160;<span class="preprocessor">#include &lt;<a class="code" href="_http_8hpp.html">enet/Http.hpp</a>&gt;</span></div><div class="line"><a name="l00009"></a><span class="lineno"> 9</span>&#160;<span class="preprocessor">#include &lt;<a class="codeRef" doxygen="/home/heero/dev/perso/out/doc/release/ememory.tag:http://atria-soft.github.io/ememory/" href="http://atria-soft.github.io/ememory/memory__8hpp.html">ememory/memory.hpp</a>&gt;</span></div><div class="line"><a name="l00010"></a><span class="lineno"> 10</span>&#160;<span class="preprocessor">#include &lt;vector&gt;</span></div><div class="line"><a name="l00011"></a><span class="lineno"> 11</span>&#160;<span class="preprocessor">#include &lt;map&gt;</span></div><div class="line"><a name="l00012"></a><span class="lineno"> 12</span>&#160;</div><div class="line"><a name="l00013"></a><span class="lineno"> 13</span>&#160;<span class="keyword">namespace </span><a class="code" href="namespaceenet.html">enet</a> {</div><div class="line"><a name="l00014"></a><span class="lineno"><a class="line" href="classenet_1_1_web_socket.html"> 14</a></span>&#160; <span class="keyword">class </span><a class="code" href="classenet_1_1_web_socket.html">WebSocket</a> {</div><div class="line"><a name="l00015"></a><span class="lineno"> 15</span>&#160; <span class="keyword">protected</span>:</div><div class="line"><a name="l00016"></a><span class="lineno"> 16</span>&#160; std::vector&lt;uint8_t&gt; m_sendBuffer;</div><div class="line"><a name="l00017"></a><span class="lineno"> 17</span>&#160; <span class="keywordtype">bool</span> m_connectionValidate;</div><div class="line"><a name="l00018"></a><span class="lineno"> 18</span>&#160; <a class="codeRef" doxygen="/home/heero/dev/perso/out/doc/release/ememory.tag:http://atria-soft.github.io/ememory/" href="http://atria-soft.github.io/ememory/classememory_1_1_shared_ptr.html">ememory::SharedPtr&lt;enet::Http&gt;</a> m_interface;</div><div class="line"><a name="l00019"></a><span class="lineno"> 19</span>&#160; std::vector&lt;uint8_t&gt; m_buffer;</div><div class="line"><a name="l00020"></a><span class="lineno"> 20</span>&#160; std::string m_checkKey;</div><div class="line"><a name="l00021"></a><span class="lineno"> 21</span>&#160; std::chrono::steady_clock::time_point m_lastReceive;</div><div class="line"><a name="l00022"></a><span class="lineno"> 22</span>&#160; std::chrono::steady_clock::time_point m_lastSend;</div><div class="line"><a name="l00023"></a><span class="lineno"> 23</span>&#160; <span class="keyword">public</span>:</div><div class="line"><a name="l00024"></a><span class="lineno"> 24</span>&#160; <span class="keyword">const</span> std::chrono::steady_clock::time_point&amp; getLastTimeReceive() {</div><div class="line"><a name="l00025"></a><span class="lineno"> 25</span>&#160; <span class="keywordflow">return</span> m_lastReceive;</div><div class="line"><a name="l00026"></a><span class="lineno"> 26</span>&#160; }</div><div class="line"><a name="l00027"></a><span class="lineno"> 27</span>&#160; <span class="keyword">const</span> std::chrono::steady_clock::time_point&amp; getLastTimeSend() {</div><div class="line"><a name="l00028"></a><span class="lineno"> 28</span>&#160; <span class="keywordflow">return</span> m_lastSend;</div><div class="line"><a name="l00029"></a><span class="lineno"> 29</span>&#160; }</div><div class="line"><a name="l00030"></a><span class="lineno"> 30</span>&#160; <span class="keyword">public</span>:</div><div class="line"><a name="l00031"></a><span class="lineno"> 31</span>&#160; <a class="code" href="classenet_1_1_web_socket.html">WebSocket</a>();</div><div class="line"><a name="l00032"></a><span class="lineno"> 32</span>&#160; <a class="code" href="classenet_1_1_web_socket.html">WebSocket</a>(<a class="code" href="classenet_1_1_tcp.html">enet::Tcp</a> _connection, <span class="keywordtype">bool</span> _isServer=<span class="keyword">false</span>);</div><div class="line"><a name="l00033"></a><span class="lineno"> 33</span>&#160; <span class="keywordtype">void</span> setInterface(<a class="code" href="classenet_1_1_tcp.html">enet::Tcp</a> _connection, <span class="keywordtype">bool</span> _isServer=<span class="keyword">false</span>);</div><div class="line"><a name="l00034"></a><span class="lineno"> 34</span>&#160; <span class="keyword">virtual</span> ~<a class="code" href="classenet_1_1_web_socket.html">WebSocket</a>();</div><div class="line"><a name="l00035"></a><span class="lineno"> 35</span>&#160; <span class="keywordtype">void</span> start(<span class="keyword">const</span> std::string&amp; _uri=<span class="stringliteral">&quot;&quot;</span>, <span class="keyword">const</span> std::vector&lt;std::string&gt;&amp; _listProtocols=std::vector&lt;std::string&gt;());</div><div class="line"><a name="l00036"></a><span class="lineno"> 36</span>&#160; <span class="keywordtype">void</span> stop(<span class="keywordtype">bool</span> _inThread=<span class="keyword">false</span>);</div><div class="line"><a name="l00037"></a><span class="lineno"> 37</span>&#160; <span class="keywordtype">bool</span> isAlive()<span class="keyword"> const </span>{</div><div class="line"><a name="l00038"></a><span class="lineno"> 38</span>&#160; <span class="keywordflow">if</span> (m_interface == <span class="keyword">nullptr</span>) {</div><div class="line"><a name="l00039"></a><span class="lineno"> 39</span>&#160; <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l00040"></a><span class="lineno"> 40</span>&#160; }</div><div class="line"><a name="l00041"></a><span class="lineno"> 41</span>&#160; <span class="keywordflow">return</span> m_interface-&gt;isAlive();</div><div class="line"><a name="l00042"></a><span class="lineno"> 42</span>&#160; }</div><div class="line"><a name="l00043"></a><span class="lineno"> 43</span>&#160; <span class="keywordtype">void</span> onReceiveData(<a class="code" href="classenet_1_1_tcp.html">enet::Tcp</a>&amp; _data);</div><div class="line"><a name="l00044"></a><span class="lineno"> 44</span>&#160; <span class="keywordtype">void</span> onReceiveRequest(<span class="keyword">const</span> <a class="code" href="classenet_1_1_http_request.html">enet::HttpRequest</a>&amp; _data);</div><div class="line"><a name="l00045"></a><span class="lineno"> 45</span>&#160; <span class="keywordtype">void</span> onReceiveAnswer(<span class="keyword">const</span> <a class="code" href="classenet_1_1_http_answer.html">enet::HttpAnswer</a>&amp; _data);</div><div class="line"><a name="l00046"></a><span class="lineno"> 46</span>&#160; <span class="keyword">protected</span>:</div><div class="line"><a name="l00047"></a><span class="lineno"> 47</span>&#160; std::string m_protocol;</div><div class="line"><a name="l00048"></a><span class="lineno"> 48</span>&#160; <span class="keyword">public</span>:</div><div class="line"><a name="l00049"></a><span class="lineno"> 49</span>&#160; <span class="keywordtype">void</span> setProtocol(<span class="keyword">const</span> std::string&amp; _protocol) {</div><div class="line"><a name="l00050"></a><span class="lineno"> 50</span>&#160; m_protocol = _protocol;</div><div class="line"><a name="l00051"></a><span class="lineno"> 51</span>&#160; }</div><div class="line"><a name="l00052"></a><span class="lineno"> 52</span>&#160; <span class="keyword">public</span>:</div><div class="line"><a name="l00053"></a><span class="lineno"><a class="line" href="classenet_1_1_web_socket.html#a39fb42e7b04f5946a8cdbb6cde6b0ce4"> 53</a></span>&#160; <span class="keyword">using</span> <a class="code" href="classenet_1_1_web_socket.html#a39fb42e7b04f5946a8cdbb6cde6b0ce4">Observer</a> = std::function&lt;void(std::vector&lt;uint8_t&gt;&amp;, bool)&gt;; </div><div class="line"><a name="l00054"></a><span class="lineno"> 54</span>&#160; <span class="keyword">protected</span>:</div><div class="line"><a name="l00055"></a><span class="lineno"> 55</span>&#160; <a class="code" href="classenet_1_1_web_socket.html#a39fb42e7b04f5946a8cdbb6cde6b0ce4">Observer</a> m_observer;</div><div class="line"><a name="l00056"></a><span class="lineno"> 56</span>&#160; <span class="keyword">public</span>:</div><div class="line"><a name="l00063"></a><span class="lineno"> 63</span>&#160; <span class="keyword">template</span>&lt;<span class="keyword">class</span> CLASS_TYPE&gt;</div><div class="line"><a name="l00064"></a><span class="lineno"><a class="line" href="classenet_1_1_web_socket.html#a3a7a4269d350a37bca2041c62e58f18f"> 64</a></span>&#160; <span class="keywordtype">void</span> <a class="code" href="classenet_1_1_web_socket.html#a3a7a4269d350a37bca2041c62e58f18f">connect</a>(CLASS_TYPE* _class, <span class="keywordtype">void</span> (CLASS_TYPE::*_func)(std::vector&lt;uint8_t&gt;&amp;, <span class="keywordtype">bool</span>)) {</div><div class="line"><a name="l00065"></a><span class="lineno"> 65</span>&#160; m_observer = [=](std::vector&lt;uint8_t&gt;&amp; _value, <span class="keywordtype">bool</span> _isString){</div><div class="line"><a name="l00066"></a><span class="lineno"> 66</span>&#160; (*_class.*_func)(_value, _isString);</div><div class="line"><a name="l00067"></a><span class="lineno"> 67</span>&#160; };</div><div class="line"><a name="l00068"></a><span class="lineno"> 68</span>&#160; }</div><div class="line"><a name="l00069"></a><span class="lineno"> 69</span>&#160; <span class="keywordtype">void</span> <a class="code" href="classenet_1_1_web_socket.html#a3a7a4269d350a37bca2041c62e58f18f">connect</a>(<a class="code" href="classenet_1_1_web_socket.html#a39fb42e7b04f5946a8cdbb6cde6b0ce4">Observer</a> _func) {</div><div class="line"><a name="l00070"></a><span class="lineno"> 70</span>&#160; m_observer = _func;</div><div class="line"><a name="l00071"></a><span class="lineno"> 71</span>&#160; }</div><div class="line"><a name="l00072"></a><span class="lineno"> 72</span>&#160; <span class="comment">// Only server:</span></div><div class="line"><a name="l00073"></a><span class="lineno"> 73</span>&#160; <span class="keyword">public</span>:</div><div class="line"><a name="l00074"></a><span class="lineno"><a class="line" href="classenet_1_1_web_socket.html#a5c234c853a0ee0b56875bb0262fc8ce0"> 74</a></span>&#160; <span class="keyword">using</span> <a class="code" href="classenet_1_1_web_socket.html#a5c234c853a0ee0b56875bb0262fc8ce0">ObserverUriCheck</a> = std::function&lt;bool(const std::string&amp;, const std::vector&lt;std::string&gt;&amp;)&gt;; </div><div class="line"><a name="l00075"></a><span class="lineno"> 75</span>&#160; <span class="keyword">protected</span>:</div><div class="line"><a name="l00076"></a><span class="lineno"> 76</span>&#160; <a class="code" href="classenet_1_1_web_socket.html#a5c234c853a0ee0b56875bb0262fc8ce0">ObserverUriCheck</a> m_observerUriCheck;</div><div class="line"><a name="l00077"></a><span class="lineno"> 77</span>&#160; <span class="keyword">public</span>:</div><div class="line"><a name="l00084"></a><span class="lineno"> 84</span>&#160; <span class="keyword">template</span>&lt;<span class="keyword">class</span> CLASS_TYPE&gt;</div><div class="line"><a name="l00085"></a><span class="lineno"><a class="line" href="classenet_1_1_web_socket.html#ab74ff78fe5f3b2161011adec69c74c19"> 85</a></span>&#160; <span class="keywordtype">void</span> <a class="code" href="classenet_1_1_web_socket.html#ab74ff78fe5f3b2161011adec69c74c19">connectUri</a>(CLASS_TYPE* _class, <span class="keywordtype">bool</span> (CLASS_TYPE::*_func)(<span class="keyword">const</span> std::string&amp;, <span class="keyword">const</span> std::vector&lt;std::string&gt;&amp;)) {</div><div class="line"><a name="l00086"></a><span class="lineno"> 86</span>&#160; m_observerUriCheck = [=](<span class="keyword">const</span> std::string&amp; _value, <span class="keyword">const</span> std::vector&lt;std::string&gt;&amp; _protocols){</div><div class="line"><a name="l00087"></a><span class="lineno"> 87</span>&#160; <span class="keywordflow">return</span> (*_class.*_func)(_value, _protocols);</div><div class="line"><a name="l00088"></a><span class="lineno"> 88</span>&#160; };</div><div class="line"><a name="l00089"></a><span class="lineno"> 89</span>&#160; }</div><div class="line"><a name="l00090"></a><span class="lineno"> 90</span>&#160; <span class="keywordtype">void</span> <a class="code" href="classenet_1_1_web_socket.html#ab74ff78fe5f3b2161011adec69c74c19">connectUri</a>(<a class="code" href="classenet_1_1_web_socket.html#a5c234c853a0ee0b56875bb0262fc8ce0">ObserverUriCheck</a> _func) {</div><div class="line"><a name="l00091"></a><span class="lineno"> 91</span>&#160; m_observerUriCheck = _func;</div><div class="line"><a name="l00092"></a><span class="lineno"> 92</span>&#160; }</div><div class="line"><a name="l00093"></a><span class="lineno"> 93</span>&#160; <span class="keyword">private</span>:</div><div class="line"><a name="l00094"></a><span class="lineno"> 94</span>&#160; <span class="keywordtype">bool</span> m_isString;</div><div class="line"><a name="l00095"></a><span class="lineno"> 95</span>&#160; <span class="keywordtype">bool</span> m_haveMask;</div><div class="line"><a name="l00096"></a><span class="lineno"> 96</span>&#160; uint8_t m_dataMask[4];</div><div class="line"><a name="l00097"></a><span class="lineno"> 97</span>&#160; <span class="keyword">public</span>:</div><div class="line"><a name="l00098"></a><span class="lineno"> 98</span>&#160; <span class="keywordtype">bool</span> configHeader(<span class="keywordtype">bool</span> _isString=<span class="keyword">false</span>, <span class="keywordtype">bool</span> _mask= <span class="keyword">false</span>);</div><div class="line"><a name="l00099"></a><span class="lineno"> 99</span>&#160; int32_t writeData(uint8_t* _data, int32_t _len);</div><div class="line"><a name="l00100"></a><span class="lineno"> 100</span>&#160; int32_t send();</div><div class="line"><a name="l00108"></a><span class="lineno"> 108</span>&#160; <span class="comment">//TODO : ...</span></div><div class="line"><a name="l00109"></a><span class="lineno"> 109</span>&#160; int32_t <a class="code" href="classenet_1_1_web_socket.html#a9c493cf31492424f7933ea7b9941cd3b">write</a>(<span class="keyword">const</span> <span class="keywordtype">void</span>* _data, int32_t _len, <span class="keywordtype">bool</span> _isString=<span class="keyword">false</span>, <span class="keywordtype">bool</span> _mask= <span class="keyword">false</span>);</div><div class="line"><a name="l00117"></a><span class="lineno"><a class="line" href="classenet_1_1_web_socket.html#ab5f62bdf3fa652db1dd7ad3801e82612"> 117</a></span>&#160; int32_t <a class="code" href="classenet_1_1_web_socket.html#ab5f62bdf3fa652db1dd7ad3801e82612">write</a>(<span class="keyword">const</span> std::string&amp; _data, <span class="keywordtype">bool</span> _writeBackSlashZero = <span class="keyword">true</span>) {</div><div class="line"><a name="l00118"></a><span class="lineno"> 118</span>&#160; <span class="keywordflow">if</span> (_data.size() == 0) {</div><div class="line"><a name="l00119"></a><span class="lineno"> 119</span>&#160; <span class="keywordflow">return</span> 0;</div><div class="line"><a name="l00120"></a><span class="lineno"> 120</span>&#160; }</div><div class="line"><a name="l00121"></a><span class="lineno"> 121</span>&#160; <span class="keywordflow">if</span> (_writeBackSlashZero == <span class="keyword">true</span>) {</div><div class="line"><a name="l00122"></a><span class="lineno"> 122</span>&#160; <span class="keywordflow">return</span> <a class="code" href="classenet_1_1_web_socket.html#a9c493cf31492424f7933ea7b9941cd3b">write</a>(_data.c_str(), _data.size()+1, <span class="keyword">true</span>);</div><div class="line"><a name="l00123"></a><span class="lineno"> 123</span>&#160; }</div><div class="line"><a name="l00124"></a><span class="lineno"> 124</span>&#160; <span class="keywordflow">return</span> <a class="code" href="classenet_1_1_web_socket.html#a9c493cf31492424f7933ea7b9941cd3b">write</a>(_data.c_str(), _data.size(), <span class="keyword">true</span>);</div><div class="line"><a name="l00125"></a><span class="lineno"> 125</span>&#160; }</div><div class="line"><a name="l00133"></a><span class="lineno"> 133</span>&#160; <span class="keyword">template</span> &lt;<span class="keyword">class</span> T&gt;</div><div class="line"><a name="l00134"></a><span class="lineno"><a class="line" href="classenet_1_1_web_socket.html#aeb3948198a6364c296727cab39a413ba"> 134</a></span>&#160; int32_t <a class="code" href="classenet_1_1_web_socket.html#aeb3948198a6364c296727cab39a413ba">write</a>(<span class="keyword">const</span> std::vector&lt;T&gt;&amp; _data) {</div><div class="line"><a name="l00135"></a><span class="lineno"> 135</span>&#160; <span class="keywordflow">if</span> (_data.size() == 0) {</div><div class="line"><a name="l00136"></a><span class="lineno"> 136</span>&#160; <span class="keywordflow">return</span> 0;</div><div class="line"><a name="l00137"></a><span class="lineno"> 137</span>&#160; }</div><div class="line"><a name="l00138"></a><span class="lineno"> 138</span>&#160; <span class="keywordtype">size_t</span> ret = <a class="code" href="classenet_1_1_web_socket.html#a9c493cf31492424f7933ea7b9941cd3b">write</a>(&amp;_data[0], _data.size()*<span class="keyword">sizeof</span>(T));</div><div class="line"><a name="l00139"></a><span class="lineno"> 139</span>&#160; <span class="keywordflow">if</span> (ret &lt;=0) {</div><div class="line"><a name="l00140"></a><span class="lineno"> 140</span>&#160; <span class="keywordflow">return</span> ret;</div><div class="line"><a name="l00141"></a><span class="lineno"> 141</span>&#160; }</div><div class="line"><a name="l00142"></a><span class="lineno"> 142</span>&#160; <span class="keywordflow">return</span> ret/<span class="keyword">sizeof</span>(T);</div><div class="line"><a name="l00143"></a><span class="lineno"> 143</span>&#160; }</div><div class="line"><a name="l00144"></a><span class="lineno"> 144</span>&#160; <span class="keyword">public</span>:</div><div class="line"><a name="l00145"></a><span class="lineno"> 145</span>&#160; <span class="keywordtype">void</span> controlPing();</div><div class="line"><a name="l00146"></a><span class="lineno"> 146</span>&#160; <span class="keywordtype">void</span> controlPong();</div><div class="line"><a name="l00147"></a><span class="lineno"> 147</span>&#160; <span class="keywordtype">void</span> controlClose();</div><div class="line"><a name="l00148"></a><span class="lineno"> 148</span>&#160; };</div><div class="line"><a name="l00149"></a><span class="lineno"> 149</span>&#160;}</div><div class="ttc" id="classenet_1_1_http_answer_html"><div class="ttname"><a href="classenet_1_1_http_answer.html">enet::HttpAnswer</a></div><div class="ttdef"><b>Definition:</b> Http.hpp:137</div></div>
<div class="ttc" id="classenet_1_1_web_socket_html_ab5f62bdf3fa652db1dd7ad3801e82612"><div class="ttname"><a href="classenet_1_1_web_socket.html#ab5f62bdf3fa652db1dd7ad3801e82612">enet::WebSocket::write</a></div><div class="ttdeci">int32_t write(const std::string &amp;_data, bool _writeBackSlashZero=true)</div><div class="ttdoc">Write a chunk of data on the socket. </div><div class="ttdef"><b>Definition:</b> WebSocket.hpp:117</div></div>
<div class="ttc" id="classenet_1_1_web_socket_html_a5c234c853a0ee0b56875bb0262fc8ce0"><div class="ttname"><a href="classenet_1_1_web_socket.html#a5c234c853a0ee0b56875bb0262fc8ce0">enet::WebSocket::ObserverUriCheck</a></div><div class="ttdeci">std::function&lt; bool(const std::string &amp;, const std::vector&lt; std::string &gt; &amp;)&gt; ObserverUriCheck</div><div class="ttdoc">Define an Observer: function pointer. </div><div class="ttdef"><b>Definition:</b> WebSocket.hpp:74</div></div>
<div class="ttc" id="classenet_1_1_web_socket_html_a39fb42e7b04f5946a8cdbb6cde6b0ce4"><div class="ttname"><a href="classenet_1_1_web_socket.html#a39fb42e7b04f5946a8cdbb6cde6b0ce4">enet::WebSocket::Observer</a></div><div class="ttdeci">std::function&lt; void(std::vector&lt; uint8_t &gt; &amp;, bool)&gt; Observer</div><div class="ttdoc">Define an Observer: function pointer. </div><div class="ttdef"><b>Definition:</b> WebSocket.hpp:53</div></div>
<div class="ttc" id="_http_8hpp_html"><div class="ttname"><a href="_http_8hpp.html">Http.hpp</a></div></div>
<div class="ttc" id="classenet_1_1_web_socket_html_ab74ff78fe5f3b2161011adec69c74c19"><div class="ttname"><a href="classenet_1_1_web_socket.html#ab74ff78fe5f3b2161011adec69c74c19">enet::WebSocket::connectUri</a></div><div class="ttdeci">void connectUri(CLASS_TYPE *_class, bool(CLASS_TYPE::*_func)(const std::string &amp;, const std::vector&lt; std::string &gt; &amp;))</div><div class="ttdoc">Connect an function member on the signal with the shared_ptr object. </div><div class="ttdef"><b>Definition:</b> WebSocket.hpp:85</div></div>
<div class="ttc" id="classenet_1_1_web_socket_html_aeb3948198a6364c296727cab39a413ba"><div class="ttname"><a href="classenet_1_1_web_socket.html#aeb3948198a6364c296727cab39a413ba">enet::WebSocket::write</a></div><div class="ttdeci">int32_t write(const std::vector&lt; T &gt; &amp;_data)</div><div class="ttdoc">Write a chunk of data on the socket. </div><div class="ttdef"><b>Definition:</b> WebSocket.hpp:134</div></div>
<div class="ttc" id="classenet_1_1_web_socket_html"><div class="ttname"><a href="classenet_1_1_web_socket.html">enet::WebSocket</a></div><div class="ttdef"><b>Definition:</b> WebSocket.hpp:14</div></div>
<div class="ttc" id="classememory_1_1_shared_ptr_html"><div class="ttname"><a href="http://atria-soft.github.io/ememory/classememory_1_1_shared_ptr.html">ememory::SharedPtr</a></div></div>
<div class="ttc" id="classenet_1_1_web_socket_html_a3a7a4269d350a37bca2041c62e58f18f"><div class="ttname"><a href="classenet_1_1_web_socket.html#a3a7a4269d350a37bca2041c62e58f18f">enet::WebSocket::connect</a></div><div class="ttdeci">void connect(CLASS_TYPE *_class, void(CLASS_TYPE::*_func)(std::vector&lt; uint8_t &gt; &amp;, bool))</div><div class="ttdoc">Connect an function member on the signal with the shared_ptr object. </div><div class="ttdef"><b>Definition:</b> WebSocket.hpp:64</div></div>
<div class="ttc" id="classenet_1_1_web_socket_html_a9c493cf31492424f7933ea7b9941cd3b"><div class="ttname"><a href="classenet_1_1_web_socket.html#a9c493cf31492424f7933ea7b9941cd3b">enet::WebSocket::write</a></div><div class="ttdeci">int32_t write(const void *_data, int32_t _len, bool _isString=false, bool _mask=false)</div><div class="ttdoc">Write a chunk of data on the socket. </div></div>
<div class="ttc" id="memory__8hpp_html"><div class="ttname"><a href="http://atria-soft.github.io/ememory/memory__8hpp.html">memory.hpp</a></div></div>
<div class="ttc" id="classenet_1_1_tcp_html"><div class="ttname"><a href="classenet_1_1_tcp.html">enet::Tcp</a></div><div class="ttdef"><b>Definition:</b> Tcp.hpp:16</div></div>
<div class="ttc" id="classenet_1_1_http_request_html"><div class="ttname"><a href="classenet_1_1_http_request.html">enet::HttpRequest</a></div><div class="ttdef"><b>Definition:</b> Http.hpp:166</div></div>
<div class="ttc" id="namespaceenet_html"><div class="ttname"><a href="namespaceenet.html">enet</a></div><div class="ttdoc">Main esvg namespace. </div><div class="ttdef"><b>Definition:</b> enet.hpp:17</div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- HTML footer for doxygen 1.8.8-->
<!-- start footer part -->
</div>
</div>
</div>
</div>
</div>
<hr class="footer"/><address class="footer"><small>
Generated on Mon Oct 24 2016 15:35:53 for enet: Ewol network abstraction by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.12
</small></address>
</body>
</html>