Repository: qpid-site Updated Branches: refs/heads/asf-site 369226a42 -> 27c60c337
http://git-wip-us.apache.org/repos/asf/qpid-site/blob/27c60c33/content/releases/qpid-proton-master/proton/cpp/api/engine_2direct_recv_8cpp-example.html ---------------------------------------------------------------------- diff --git a/content/releases/qpid-proton-master/proton/cpp/api/engine_2direct_recv_8cpp-example.html b/content/releases/qpid-proton-master/proton/cpp/api/engine_2direct_recv_8cpp-example.html deleted file mode 100755 index 5d4e1ff..0000000 --- a/content/releases/qpid-proton-master/proton/cpp/api/engine_2direct_recv_8cpp-example.html +++ /dev/null @@ -1,190 +0,0 @@ -<!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="Content-Type" content="text/xhtml;charset=UTF-8"/> -<meta http-equiv="X-UA-Compatible" content="IE=9"/> -<meta name="generator" content="Doxygen 1.8.10"/> -<title>Qpid Proton C++ API: engine/direct_recv.cpp</title> -<link href="tabs.css" rel="stylesheet" type="text/css"/> -<script type="text/javascript" src="jquery.js"></script> -<script type="text/javascript" src="dynsections.js"></script> -<link href="navtree.css" rel="stylesheet" type="text/css"/> -<script type="text/javascript" src="resize.js"></script> -<script type="text/javascript" src="navtreedata.js"></script> -<script type="text/javascript" src="navtree.js"></script> -<script type="text/javascript"> - $(document).ready(initResizable); - $(window).load(resizeHeight); -</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> -<script type="text/javascript"> - $(document).ready(function() { init_search(); }); -</script> -<link href="doxygen.css" rel="stylesheet" type="text/css" /> -</head> -<body> -<div id="top"><!-- do not remove this div, it is closed by doxygen! --> -<div id="titlearea"> -<table cellspacing="0" cellpadding="0"> - <tbody> - <tr style="height: 56px;"> - <td id="projectalign" style="padding-left: 0.5em;"> - <div id="projectname">Qpid Proton C++ API -  <span id="projectnumber">master</span> - </div> - </td> - <td> <div id="MSearchBox" class="MSearchBoxInactive"> - <span class="left"> - <img id="MSearchSelect" src="search/mag_sel.png" - onmouseover="return searchBox.OnSearchSelectShow()" - onmouseout="return searchBox.OnSearchSelectHide()" - alt=""/> - <input type="text" id="MSearchField" value="Search" accesskey="S" - onfocus="searchBox.OnSearchFieldFocus(true)" - onblur="searchBox.OnSearchFieldFocus(false)" - onkeyup="searchBox.OnSearchFieldChange(event)"/> - </span><span class="right"> - <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a> - </span> - </div> -</td> - </tr> - </tbody> -</table> -</div> -<!-- end header part --> -<!-- Generated by Doxygen 1.8.10 --> -<script type="text/javascript"> -var searchBox = new SearchBox("searchBox", "search",false,'Search'); -</script> -</div><!-- top --> -<div id="side-nav" class="ui-resizable side-nav-resizable"> - <div id="nav-tree"> - <div id="nav-tree-contents"> - <div id="nav-sync" class="sync"></div> - </div> - </div> - <div id="splitbar" style="-moz-user-select:none;" - class="ui-resizable-handle"> - </div> -</div> -<script type="text/javascript"> -$(document).ready(function(){initNavTree('engine_2direct_recv_8cpp-example.html','');}); -</script> -<div id="doc-content"> -<!-- 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 class="header"> - <div class="headertitle"> -<div class="title">engine/direct_recv.cpp</div> </div> -</div><!--header--> -<div class="contents"> -<p><code><a class="el" href="classproton_1_1connection__engine.html" title="An interface for connection-oriented IO integration. ">proton::connection_engine</a></code> example accepts an incoming connection and then receives like <code>simple_recv</code>. You can connect directly to <code>direct_recv</code> without* a broker using <a class="el" href="simple_send_8cpp-example.html">simple_send.cpp</a>. Make sure to stop the broker first or use a different port for <code>direct_recv</code>.</p> -<div class="fragment"><div class="line"><span class="comment">/*</span></div> -<div class="line"><span class="comment"> *</span></div> -<div class="line"><span class="comment"> * Licensed to the Apache Software Foundation (ASF) under one</span></div> -<div class="line"><span class="comment"> * or more contributor license agreements. See the NOTICE file</span></div> -<div class="line"><span class="comment"> * distributed with this work for additional information</span></div> -<div class="line"><span class="comment"> * regarding copyright ownership. The ASF licenses this file</span></div> -<div class="line"><span class="comment"> * to you under the Apache License, Version 2.0 (the</span></div> -<div class="line"><span class="comment"> * "License"); you may not use this file except in compliance</span></div> -<div class="line"><span class="comment"> * with the License. You may obtain a copy of the License at</span></div> -<div class="line"><span class="comment"> *</span></div> -<div class="line"><span class="comment"> * http://www.apache.org/licenses/LICENSE-2.0</span></div> -<div class="line"><span class="comment"> *</span></div> -<div class="line"><span class="comment"> * Unless required by applicable law or agreed to in writing,</span></div> -<div class="line"><span class="comment"> * software distributed under the License is distributed on an</span></div> -<div class="line"><span class="comment"> * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY</span></div> -<div class="line"><span class="comment"> * KIND, either express or implied. See the License for the</span></div> -<div class="line"><span class="comment"> * specific language governing permissions and limitations</span></div> -<div class="line"><span class="comment"> * under the License.</span></div> -<div class="line"><span class="comment"> *</span></div> -<div class="line"><span class="comment"> */</span></div> -<div class="line"></div> -<div class="line"><span class="preprocessor">#include "options.hpp"</span></div> -<div class="line"></div> -<div class="line"><span class="preprocessor">#include "proton/io.hpp"</span></div> -<div class="line"><span class="preprocessor">#include "proton/event.hpp"</span></div> -<div class="line"><span class="preprocessor">#include "proton/handler.hpp"</span></div> -<div class="line"><span class="preprocessor">#include "proton/link.hpp"</span></div> -<div class="line"><span class="preprocessor">#include "proton/url.hpp"</span></div> -<div class="line"><span class="preprocessor">#include "proton/value.hpp"</span></div> -<div class="line"></div> -<div class="line"><span class="preprocessor">#include <iostream></span></div> -<div class="line"><span class="preprocessor">#include <map></span></div> -<div class="line"></div> -<div class="line"><span class="keyword">class </span>direct_recv : <span class="keyword">public</span> <a name="_a0"></a><a class="code" href="classproton_1_1handler.html">proton::handler</a> {</div> -<div class="line"> <span class="keyword">private</span>:</div> -<div class="line"> uint64_t expected;</div> -<div class="line"> uint64_t received;</div> -<div class="line"></div> -<div class="line"> <span class="keyword">public</span>:</div> -<div class="line"> direct_recv(<span class="keywordtype">int</span> c) : expected(c), received(0) {}</div> -<div class="line"></div> -<div class="line"> <span class="keywordtype">void</span> <a name="a1"></a><a class="code" href="classproton_1_1handler.html#a853f861e091fdb37b69d94be1b0ea032">on_start</a>(<a name="_a2"></a><a class="code" href="classproton_1_1event.html">proton::event</a> &e) {</div> -<div class="line"> e.<a name="a3"></a><a class="code" href="classproton_1_1event.html#a89bfeade377f12d843e51d16c353a556">connection</a>().open();</div> -<div class="line"> }</div> -<div class="line"></div> -<div class="line"> <span class="keywordtype">void</span> <a name="a4"></a><a class="code" href="classproton_1_1handler.html#ade01b01951064667a5a076362c5e61ef">on_message</a>(<a class="code" href="classproton_1_1event.html">proton::event</a> &e) {</div> -<div class="line"> <a name="_a5"></a><a class="code" href="classproton_1_1message.html">proton::message</a>& msg = e.<a name="a6"></a><a class="code" href="classproton_1_1event.html#a05e07a1a99eaa74c1a3288511b15cae5">message</a>();</div> -<div class="line"> <span class="keywordflow">if</span> (msg.<a name="a7"></a>id().get<uint64_t>() < received)</div> -<div class="line"> <span class="keywordflow">return</span>; <span class="comment">// ignore duplicate</span></div> -<div class="line"> <span class="keywordflow">if</span> (expected == 0 || received < expected) {</div> -<div class="line"> std::cout << msg.<a name="a8"></a><a class="code" href="classproton_1_1message.html#ae9af642f154a68ec0eb8e715ecaf95ae">body</a>() << std::endl;</div> -<div class="line"> received++;</div> -<div class="line"> }</div> -<div class="line"> <span class="keywordflow">if</span> (received == expected) {</div> -<div class="line"> e.<a name="a9"></a><a class="code" href="classproton_1_1event.html#a7addccdd75bcff734183d97f241795cf">receiver</a>().<a name="a10"></a><a class="code" href="classproton_1_1link.html#a5ae591df94fc66ccb85cbb6565368bca">close</a>();</div> -<div class="line"> e.<a class="code" href="classproton_1_1event.html#a89bfeade377f12d843e51d16c353a556">connection</a>().<a name="a11"></a><a class="code" href="classproton_1_1connection.html#a5ae591df94fc66ccb85cbb6565368bca">close</a>();</div> -<div class="line"> }</div> -<div class="line"> }</div> -<div class="line">};</div> -<div class="line"></div> -<div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv) {</div> -<div class="line"> <span class="comment">// Command line options</span></div> -<div class="line"> std::string address(<span class="stringliteral">"127.0.0.1:5672/examples"</span>);</div> -<div class="line"> <span class="keywordtype">int</span> message_count = 100;</div> -<div class="line"> options opts(argc, argv);</div> -<div class="line"> opts.add_value(address, <span class="charliteral">'a'</span>, <span class="stringliteral">"address"</span>, <span class="stringliteral">"listen and receive on URL"</span>, <span class="stringliteral">"URL"</span>);</div> -<div class="line"> opts.add_value(message_count, <span class="charliteral">'m'</span>, <span class="stringliteral">"messages"</span>, <span class="stringliteral">"receive COUNT messages"</span>, <span class="stringliteral">"COUNT"</span>);</div> -<div class="line"> <span class="keywordflow">try</span> {</div> -<div class="line"> opts.parse();</div> -<div class="line"> <a name="_a12"></a><a class="code" href="classproton_1_1url.html">proton::url</a> url(address);</div> -<div class="line"> <a name="_a13"></a><a class="code" href="classproton_1_1io_1_1listener.html">proton::io::listener</a> listener(url.host(), url.port());</div> -<div class="line"> std::cout << <span class="stringliteral">"direct_recv listening on "</span> << url << std::endl;</div> -<div class="line"> direct_recv handler(message_count);</div> -<div class="line"> <a name="_a14"></a><a class="code" href="classproton_1_1io_1_1socket__engine.html">proton::io::socket_engine</a>(listener.accept(), handler).run();</div> -<div class="line"> <span class="keywordflow">return</span> 0;</div> -<div class="line"> } <span class="keywordflow">catch</span> (<span class="keyword">const</span> bad_option& e) {</div> -<div class="line"> std::cout << opts << std::endl << e.what() << std::endl;</div> -<div class="line"> } <span class="keywordflow">catch</span> (<span class="keyword">const</span> std::exception& e) {</div> -<div class="line"> std::cerr << e.what() << std::endl;</div> -<div class="line"> }</div> -<div class="line"> <span class="keywordflow">return</span> 1;</div> -<div class="line">}</div> -</div><!-- fragment --> </div><!-- contents --> -</div><!-- doc-content --> -<!-- start footer part --> -<div id="nav-path" class="navpath"><!-- id is needed for treeview function! --> - <ul> - <li class="footer">Generated by - <a href="http://www.doxygen.org/index.html"> - <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.10 </li> - </ul> -</div> -</body> -</html> --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
