1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Wt examples: /home/koen/project/wt/public-git/wt/examples/simplechat/SimpleChatServer.h Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.6 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li><a href="annotated.html"><span>Classes</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<h1>/home/koen/project/wt/public-git/wt/examples/simplechat/SimpleChatServer.h</h1><a href="SimpleChatServer_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// This may look like C code, but it's really -*- C++ -*-</span>
<a name="l00002"></a>00002 <span class="comment">/*</span>
<a name="l00003"></a>00003 <span class="comment"> * Copyright (C) 2008 Emweb bvba, Heverlee, Belgium.</span>
<a name="l00004"></a>00004 <span class="comment"> *</span>
<a name="l00005"></a>00005 <span class="comment"> * See the LICENSE file for terms of use.</span>
<a name="l00006"></a>00006 <span class="comment"> */</span>
<a name="l00007"></a>00007 <span class="preprocessor">#ifndef SIMPLECHATSERVER_H_</span>
<a name="l00008"></a>00008 <span class="preprocessor"></span><span class="preprocessor">#define SIMPLECHATSERVER_H_</span>
<a name="l00009"></a>00009 <span class="preprocessor"></span>
<a name="l00010"></a>00010 <span class="preprocessor">#include <Wt/WObject></span>
<a name="l00011"></a>00011 <span class="preprocessor">#include <Wt/WSignal></span>
<a name="l00012"></a>00012 <span class="preprocessor">#include <Wt/WString></span>
<a name="l00013"></a>00013
<a name="l00014"></a>00014 <span class="preprocessor">#include <set></span>
<a name="l00015"></a>00015 <span class="preprocessor">#include <boost/thread.hpp></span>
<a name="l00016"></a>00016
<a name="l00021"></a>00021
<a name="l00024"></a><a class="code" href="classChatEvent.html">00024</a> <span class="keyword">class </span><a class="code" href="classChatEvent.html" title="Encapsulate a chat event.">ChatEvent</a>
<a name="l00025"></a>00025 {
<a name="l00026"></a>00026 <span class="keyword">public</span>:
<a name="l00029"></a><a class="code" href="classChatEvent.html#fa84446dae17c08fe15cf932fc0b7d61">00029</a> <span class="keyword">enum</span> <a class="code" href="classChatEvent.html#fa84446dae17c08fe15cf932fc0b7d61" title="Enumeration for the event type.">Type</a> { <a class="code" href="classChatEvent.html#fa84446dae17c08fe15cf932fc0b7d615173cb4baa818f95af4604d7a01e3ae6">Login</a>, <a class="code" href="classChatEvent.html#fa84446dae17c08fe15cf932fc0b7d61a8b11c1512738c200b2cfe1facd1c171">Logout</a>, <a class="code" href="classChatEvent.html#fa84446dae17c08fe15cf932fc0b7d61b8894351cd11a316e25495f677eb9ae1">Message</a> };
<a name="l00030"></a>00030
<a name="l00033"></a><a class="code" href="classChatEvent.html#c932234e63d23080f4f91f7ae1167418">00033</a> <a class="code" href="classChatEvent.html#fa84446dae17c08fe15cf932fc0b7d61" title="Enumeration for the event type.">Type</a> <a class="code" href="classChatEvent.html#c932234e63d23080f4f91f7ae1167418" title="Get the event type.">type</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classChatEvent.html#8a55c20da17f812694469924b04bfd4c">type_</a>; }
<a name="l00034"></a>00034
<a name="l00037"></a><a class="code" href="classChatEvent.html#dbeff19aece69e75ab0b69f2adecc5b6">00037</a> <span class="keyword">const</span> <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WString.html">Wt::WString</a>& <a class="code" href="classChatEvent.html#dbeff19aece69e75ab0b69f2adecc5b6" title="Get the user who caused the event.">user</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classChatEvent.html#3e2d08dca6b95343ad494e796a320eec">user_</a>; }
<a name="l00038"></a>00038
<a name="l00041"></a><a class="code" href="classChatEvent.html#1e73c4e7d9a59d790d4ba3a5bb36902d">00041</a> <span class="keyword">const</span> <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WString.html">Wt::WString</a>& <a class="code" href="classChatEvent.html#1e73c4e7d9a59d790d4ba3a5bb36902d" title="Get the message of the event.">message</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classChatEvent.html#d51677c773550286593db4793dae62eb">message_</a>; }
<a name="l00042"></a>00042
<a name="l00045"></a>00045 <span class="keyword">const</span> <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WString.html">Wt::WString</a> <a class="code" href="classChatEvent.html#6df1eda449e68e7f29644e68919b2f3f" title="Get the message formatted as HTML, rendered for the given user.">formattedHTML</a>(<span class="keyword">const</span> <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WString.html">Wt::WString</a>& <a class="code" href="classChatEvent.html#dbeff19aece69e75ab0b69f2adecc5b6" title="Get the user who caused the event.">user</a>) <span class="keyword">const</span>;
<a name="l00046"></a>00046
<a name="l00047"></a>00047 <span class="keyword">private</span>:
<a name="l00048"></a><a class="code" href="classChatEvent.html#8a55c20da17f812694469924b04bfd4c">00048</a> <a class="code" href="classChatEvent.html#fa84446dae17c08fe15cf932fc0b7d61" title="Enumeration for the event type.">Type</a> <a class="code" href="classChatEvent.html#8a55c20da17f812694469924b04bfd4c">type_</a>;
<a name="l00049"></a><a class="code" href="classChatEvent.html#3e2d08dca6b95343ad494e796a320eec">00049</a> <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WString.html">Wt::WString</a> <a class="code" href="classChatEvent.html#3e2d08dca6b95343ad494e796a320eec">user_</a>;
<a name="l00050"></a><a class="code" href="classChatEvent.html#d51677c773550286593db4793dae62eb">00050</a> <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WString.html">Wt::WString</a> <a class="code" href="classChatEvent.html#d51677c773550286593db4793dae62eb">message_</a>;
<a name="l00051"></a>00051
<a name="l00052"></a>00052 <span class="comment">/*</span>
<a name="l00053"></a>00053 <span class="comment"> * Both user and html will be formatted as html</span>
<a name="l00054"></a>00054 <span class="comment"> */</span>
<a name="l00055"></a><a class="code" href="classChatEvent.html#87e8c95da862b11466c9de1c9039cf6b">00055</a> <a class="code" href="classChatEvent.html#87e8c95da862b11466c9de1c9039cf6b">ChatEvent</a>(<span class="keyword">const</span> <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WString.html">Wt::WString</a>& <a class="code" href="classChatEvent.html#dbeff19aece69e75ab0b69f2adecc5b6" title="Get the user who caused the event.">user</a>, <span class="keyword">const</span> <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WString.html">Wt::WString</a>& <a class="code" href="classChatEvent.html#1e73c4e7d9a59d790d4ba3a5bb36902d" title="Get the message of the event.">message</a>)
<a name="l00056"></a>00056 : <a class="code" href="classChatEvent.html#8a55c20da17f812694469924b04bfd4c">type_</a>(<a class="code" href="classChatEvent.html#fa84446dae17c08fe15cf932fc0b7d61b8894351cd11a316e25495f677eb9ae1">Message</a>), <a class="code" href="classChatEvent.html#3e2d08dca6b95343ad494e796a320eec">user_</a>(user), <a class="code" href="classChatEvent.html#d51677c773550286593db4793dae62eb">message_</a>(message)
<a name="l00057"></a>00057 { }
<a name="l00058"></a>00058
<a name="l00059"></a><a class="code" href="classChatEvent.html#0de96374c741103cfaad930afae315c3">00059</a> <a class="code" href="classChatEvent.html#87e8c95da862b11466c9de1c9039cf6b">ChatEvent</a>(<a class="code" href="classChatEvent.html#fa84446dae17c08fe15cf932fc0b7d61" title="Enumeration for the event type.">Type</a> <a class="code" href="classChatEvent.html#c932234e63d23080f4f91f7ae1167418" title="Get the event type.">type</a>, <span class="keyword">const</span> <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WString.html">Wt::WString</a>& <a class="code" href="classChatEvent.html#dbeff19aece69e75ab0b69f2adecc5b6" title="Get the user who caused the event.">user</a>)
<a name="l00060"></a>00060 : <a class="code" href="classChatEvent.html#8a55c20da17f812694469924b04bfd4c">type_</a>(type), <a class="code" href="classChatEvent.html#3e2d08dca6b95343ad494e796a320eec">user_</a>(user)
<a name="l00061"></a>00061 { }
<a name="l00062"></a>00062
<a name="l00063"></a><a class="code" href="classChatEvent.html#c99c17370c25b3c92dbb0578e4298ade">00063</a> <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classSimpleChatServer.html" title="A simple chat server.">SimpleChatServer</a>;
<a name="l00064"></a>00064 };
<a name="l00065"></a>00065
<a name="l00068"></a><a class="code" href="classSimpleChatServer.html">00068</a> <span class="keyword">class </span><a class="code" href="classSimpleChatServer.html" title="A simple chat server.">SimpleChatServer</a> : <span class="keyword">public</span> Wt::<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WObject.html#1da12f5d82488adcca912c596b9398ea">WObject</a>
<a name="l00069"></a>00069 {
<a name="l00070"></a>00070 <span class="keyword">public</span>:
<a name="l00073"></a>00073 <a class="code" href="classSimpleChatServer.html#b333561090906f3cb1bf79acd4e9b9b4" title="Create a new chat server.">SimpleChatServer</a>();
<a name="l00074"></a>00074
<a name="l00079"></a>00079 <span class="keywordtype">bool</span> <a class="code" href="classSimpleChatServer.html#da0ab17464e1711ca15f30b381ede57c" title="Try to login with given user name.">login</a>(<span class="keyword">const</span> <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WString.html">Wt::WString</a>& user);
<a name="l00080"></a>00080
<a name="l00083"></a>00083 <span class="keywordtype">void</span> <a class="code" href="classSimpleChatServer.html#5d376e3ff441f24843be648dd420e027" title="Logout from the server.">logout</a>(<span class="keyword">const</span> <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WString.html">Wt::WString</a>& user);
<a name="l00084"></a>00084
<a name="l00087"></a>00087 <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WString.html">Wt::WString</a> <a class="code" href="classSimpleChatServer.html#bf692567706118193111c2b2589c8d3f" title="Get a suggestion for a guest user name.">suggestGuest</a>();
<a name="l00088"></a>00088
<a name="l00091"></a>00091 <span class="keywordtype">void</span> <a class="code" href="classSimpleChatServer.html#ab42074f7904397b3547a6df89c16d9d" title="Send a message on behalve of a user.">sendMessage</a>(<span class="keyword">const</span> <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WString.html">Wt::WString</a>& user, <span class="keyword">const</span> <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WString.html">Wt::WString</a>& message);
<a name="l00092"></a>00092
<a name="l00097"></a><a class="code" href="classSimpleChatServer.html#baf4e2a4e3e17b14e208146b0251f7ab">00097</a> <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1Signal.html">Wt::Signal<ChatEvent></a>& <a class="code" href="classSimpleChatServer.html#baf4e2a4e3e17b14e208146b0251f7ab" title="Signal that will convey chat events.">chatEvent</a>() { <span class="keywordflow">return</span> <a class="code" href="classSimpleChatServer.html#c6640dc1ee3ea640de38c1896452b91a">chatEvent_</a>; }
<a name="l00098"></a>00098
<a name="l00101"></a><a class="code" href="classSimpleChatServer.html#911329f24472ca7ed245ab18611488d4">00101</a> <span class="keyword">typedef</span> std::set<Wt::WString> <a class="code" href="classSimpleChatServer.html#911329f24472ca7ed245ab18611488d4" title="Typedef for a collection of user names.">UserSet</a>;
<a name="l00102"></a>00102
<a name="l00105"></a>00105 <a class="code" href="classSimpleChatServer.html#911329f24472ca7ed245ab18611488d4" title="Typedef for a collection of user names.">UserSet</a> <a class="code" href="classSimpleChatServer.html#40f5c6465b1edb44278be93c97a29a39" title="Get the users currently logged in.">users</a>();
<a name="l00106"></a>00106
<a name="l00107"></a>00107 <span class="keyword">private</span>:
<a name="l00108"></a><a class="code" href="classSimpleChatServer.html#c6640dc1ee3ea640de38c1896452b91a">00108</a> <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1Signal.html">Wt::Signal<ChatEvent></a> <a class="code" href="classSimpleChatServer.html#c6640dc1ee3ea640de38c1896452b91a">chatEvent_</a>;
<a name="l00109"></a><a class="code" href="classSimpleChatServer.html#949e434d4255597989d74f17faca674b">00109</a> boost::mutex <a class="code" href="classSimpleChatServer.html#949e434d4255597989d74f17faca674b">mutex_</a>;
<a name="l00110"></a>00110
<a name="l00111"></a><a class="code" href="classSimpleChatServer.html#e6712308cbb1f6b1ff4024630ea1d20c">00111</a> <a class="code" href="classSimpleChatServer.html#911329f24472ca7ed245ab18611488d4" title="Typedef for a collection of user names.">UserSet</a> <a class="code" href="classSimpleChatServer.html#e6712308cbb1f6b1ff4024630ea1d20c">users_</a>;
<a name="l00112"></a>00112 };
<a name="l00113"></a>00113
<a name="l00116"></a>00116 <span class="preprocessor">#endif // SIMPLECHATSERVER_H_</span>
</pre></div></div>
<hr size="1"><address style="align: right;"><small>
Generated on Fri Mar 26 17:12:12 2010 for <a href="http://www.webtoolkit.eu/wt/">Wt</a> by <a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.6</small></address>
</body>
</html>
|