Skip to content

Commit b08be7f

Browse files
subscriber_main.cpp
1 parent d16a7e3 commit b08be7f

File tree

1 file changed

+42
-11
lines changed

1 file changed

+42
-11
lines changed

doc/settAug2013/liquibook_sett.html

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2329,7 +2329,7 @@ <h3>Handling Liquibook Events</h3>
23292329
} } // End namespace
23302330
</pre>
23312331

2332-
<h3>Initialization</h3>
2332+
<h3>Publisher Initialization</h3>
23332333
<p>
23342334
At this point the publisher has all the necessary parts to publish a trade
23352335
feed and an incremental depth feed for the exchange. The only things that
@@ -2887,6 +2887,7 @@ <h2>Subscriber Application</h2>
28872887
<p>
28882888
The final helper method handles a trade message:
28892889
</p>
2890+
28902891
<div class="listing">depth_feed_subscriber.h: DepthFeedSubscriber class implementation, continued</div>
28912892
<pre class="code">
28922893
bool
@@ -2927,23 +2928,53 @@ <h2>Subscriber Application</h2>
29272928
size). The result is then logged.
29282929
</p>
29292930

2930-
<h2>Final Big Topic</h2>
2931+
<h3>Subscriber Initialization</h3>
29312932

29322933
<p>
2933-
Here is how to include blocks of code in the article using the &lt;pre&gt; tag and syntax highlighter:
2934+
Finally, the subscriber can create, initialize, and associate its components.
2935+
The <code>main()</code> function of subscriber starts by creating the
2936+
<code>DepthFeedConnection</code> and the <code>DepthFeedSubscriber</code>:
29342937
</p>
29352938

2936-
<pre class="brush: java">
2937-
import java.io.*;
2939+
<div class="listing">subscriber_main.cpp: main() function</div>
2940+
<pre class="code">
2941+
int main(int argc, const char* argv[])
2942+
{
2943+
// Create the connection
2944+
liquibook::examples::DepthFeedConnection connection(argc, argv);
2945+
2946+
// Create feed subscriber
2947+
liquibook::examples::DepthFeedSubscriber feed(connection.get_templates());
2948+
2949+
// Set up handlers
2950+
liquibook::examples::MessageHandler msg_handler =
2951+
boost::bind(&amp;liquibook::examples::DepthFeedSubscriber::handle_message,
2952+
&amp;feed, _1, _2);
2953+
liquibook::examples::ResetHandler reset_handler =
2954+
boost::bind(&amp;liquibook::examples::DepthFeedSubscriber::handle_reset,
2955+
&amp;feed);
2956+
connection.set_message_handler(msg_handler);
2957+
connection.set_reset_handler(reset_handler);
2958+
2959+
// Connect to server
2960+
connection.connect();
2961+
connection.run();
29382962

2939-
public class Foobar extends Whatever {
2940-
public static void main(String[] args) {
2941-
<span class="green">// 4-space indent according to JavaSoft conventions</span>
2942-
}
2943-
}
2963+
return 0;
2964+
}
29442965
</pre>
29452966

2946-
<p>Now describe the code.</p>
2967+
<p>
2968+
Next, the handlers for messages, and connection resets are set up, and
2969+
finally, the subscriber connects to the publisher. This completes the
2970+
subscriber application.
2971+
</p>
2972+
2973+
<h2>Running the Example</h2>
2974+
2975+
<p>
2976+
Here is how to include blocks of code in the article using the &lt;pre&gt; tag and syntax highlighter:
2977+
</p>
29472978

29482979
<h2>Summary</h2>
29492980

0 commit comments

Comments
 (0)