Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > media > main-release > by-pkgid > ea24284f03fd4a8a4b64047514d93f64 > files > 201

lib64kdegames1-devel-3.5.9-2mdv2008.1.x86_64.rpm

<?xml version="1.0" encoding="UTF-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" lang="en_US" xml:lang="en_US">

<head>
  <title>libkdegames: KMessageServer Class Reference (libkdegames)</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

  <meta http-equiv="Content-Style-Type" content="text/css" />

  <meta http-equiv="pics-label" content='(pics-1.1 "http://www.icra.org/ratingsv02.html" comment "ICRAonline DE v2.0" l gen true for "http://www.kde.org"  r (nz 1 vz 1 lz 1 oz 1 cb 1) "http://www.rsac.org/ratingsv01.html" l gen true for "http://www.kde.org"  r (n 0 s 0 v 0 l 0))' />

  <meta name="trademark" content="KDE e.V." />
  <meta name="description" content="K Desktop Environment Homepage, KDE.org" />
  <meta name="MSSmartTagsPreventParsing" content="true" />
  <meta name="robots" content="all" />

  <link rel="shortcut icon" href="../../favicon.ico" />

<link rel="stylesheet" media="screen" type="text/css" title="APIDOX" href="doxygen.css" />



</head>

<body>

<div id="nav_header_top" align="right">
  <a href="#content" class="doNotDisplay" accesskey="2">Skip to main content ::</a>

  <a href="../.."><img id="nav_header_logo" alt="Home" align="left" src="../../kde_gear_64.png" border="0" /></a>
  <span class="doNotDisplay">::</span>

  <div id="nav_header_title" align="left">KDE API Reference</div>


</div>

<div id="nav_header_bottom" align="right">
  <span class="doNotDisplay">:: <a href="#navigation" accesskey="5">Skip to Link Menu</a><br/></span>
  <div id="nav_header_bottom_right" style="text-align: left;">
/ <a href="../..">API Reference</a>
 / <a href=".">libkdegames</a>
  </div>
</div>


<table id="main" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
      <td valign="top" class="menuheader" height="0"></td>

  <td id="contentcolumn" valign="top" rowspan="2" >
    <div id="content" style="padding-top: 0px;"><div style="width:100%; margin: 0px; padding: 0px;">
    <a name="content"></a>


<!-- Generated by Doxygen 1.5.5 -->
<div class="contents">
<h1>KMessageServer Class Reference</h1><!-- doxytag: class="KMessageServer" --><!-- doxytag: inherits="QObject" --><code>#include &lt;<a class="el" href="kmessageserver_8h-source.html">kmessageserver.h</a>&gt;</code>
<p>
Inherits QObject.
<p>

<p>
<a href="classKMessageServer-members.html">List of all members.</a><hr><a name="_details"></a><h2>Detailed Description</h2>
A server for message sending and broadcasting, using TCP/IP connections. 
<p>
An object of this class listens for incoming connections via TCP/IP sockets and creates <a class="el" href="classKMessageSocket.html" title="This class implements the message communication using a TCP/IP socket.">KMessageSocket</a> objects for every established connection. It receives messages from the "clients", analyses them and processes an appropriate reaction.<p>
You can also use other <a class="el" href="classKMessageIO.html" title="This abstract base class represents one end of a message connections between two...">KMessageIO</a> objects with <a class="el" href="classKMessageServer.html" title="A server for message sending and broadcasting, using TCP/IP connections.">KMessageServer</a>, not only TCP/IP socket based ones. Use addClient to connect via an object of any <a class="el" href="classKMessageIO.html" title="This abstract base class represents one end of a message connections between two...">KMessageIO</a> subclass. (For clients within the same process, you can e.g. use <a class="el" href="classKMessageDirect.html" title="This class implements the message communication using function calls directly.">KMessageDirect</a>.) This object already has to be connected.<p>
The messages are always packages of an arbitrary length. The format of the messages is given below. All the data is stored and received with QDataStream, to be platform independant.<p>
Setting up a <a class="el" href="classKMessageServer.html" title="A server for message sending and broadcasting, using TCP/IP connections.">KMessageServer</a> can be done like this:<p>
<div class="fragment"><pre class="fragment">    <a class="code" href="classKMessageServer.html" title="A server for message sending and broadcasting, using TCP/IP connections.">KMessageServer</a> *server = <span class="keyword">new</span> <a class="code" href="classKMessageServer.html#56f63c95fa8f210cb55069fa77605371" title="Create a KGameNetwork object.">KMessageServer</a> ();
    server-&gt;<a class="code" href="classKMessageServer.html#0501651eb0590202bbd2663f8646a238" title="Starts the Communication server to listen for incoming TCP/IP connections.">initNetwork</a> (TCP/IP-Portnumber);
</pre></div><p>
Usually that is everything you will do. There are a lot of public methods to administrate the object (maximum number of clients, finding clients, removing clients, setting the admin client, ...), but this functionality can also be done by messages from the clients. So you can administrate the object completely on remote.<p>
If you want to extend the Server for your own needs (e.g. additional message types), you can either create a subclass and overwrite the method processOneMessage. (But don't forget to call the method of the superclass!) Or you can connect to the signal messageReceived, and analyse the messages there.<p>
Every client has a unique ID, so that messages can be sent to another dedicated client or a list of clients.<p>
One of the clients (the admin) has a special administration right. Some of the administration messages can only be used with him. The admin can give the admin status to another client. You can send a message to the admin by using clientID 0. This is always interpreted as the admin client, independant of its real clientID.<p>
Here is a list of the messages the <a class="el" href="classKMessageServer.html" title="A server for message sending and broadcasting, using TCP/IP connections.">KMessageServer</a> understands: &lt;&lt; means, the value is inserted into the QByteArray using QDataStream. The messageIDs (REQ_BROADCAST, ...) are of type Q_UINT32.<p>
<ul>
<li>QByteArray &lt;&lt; static_cast&lt;Q_UINT32&gt;( REQ_BROADCAST ) &lt;&lt; raw_data</li></ul>
<p>
When the server receives this message, it sends the following message to ALL connected clients (a broadcast), where the raw_data is left unchanged: QByteArray &lt;&lt; static_cast &lt;Q_UINT32&gt;( MSG_BROADCAST ) &lt;&lt; clientID &lt;&lt; raw_data Q_UINT32 clientID; // the ID of the client that sent the broadcast request<p>
<ul>
<li>QByteArray &lt;&lt; static_cast&lt;Q_UINT32&gt;( REQ_FORWARD ) &lt;&lt; client_list &lt;&lt; raw_data QValueList &lt;Q_UINT32&gt; client_list; // list of receivers</li></ul>
<p>
When the server receives this message, it sends the following message to the clients in client_list: QByteArray &lt;&lt; static_cast&lt;Q_UINT32&gt;( MSG_FORWARD ) &lt;&lt; senderID &lt;&lt; client_list &lt;&lt; raw_data Q_UINT32 senderID; // the sender of the forward request QValueList &lt;Q_UINT32&gt; client_list; // a copy of the receiver list<p>
Note: Every client receives the message as many times as he is in the client_list. Note: Since the client_list is sent to all the clients, every client can see who else got the message. If you want to prevent this, send a single REQ_FORWARD message for every receiver.<p>
<ul>
<li>QByteArray &lt;&lt; static_cast&lt;Q_UINT32&gt;( REQ_CLIENT_ID )</li></ul>
<p>
When the server receives this message, it sends the following message to the asking client: QByteArray &lt;&lt; static_cast&lt;Q_UINT32&gt;( ANS_CLIENT_ID ) &lt;&lt; clientID Q_UINT32 clientID; // The ID of the client who asked for it<p>
Note: This answer is also automatically sent to a new connected client, so that he can store his ID. The ID of a client doesn't change during his lifetime, and is unique for this <a class="el" href="classKMessageServer.html" title="A server for message sending and broadcasting, using TCP/IP connections.">KMessageServer</a>.<p>
<ul>
<li>QByteArray &lt;&lt; static_cast&lt;Q_UINT32&gt;( REQ_ADMIN_ID )</li></ul>
<p>
When the server receives this message, it sends the following message to the asking client: QByteArray &lt;&lt; ANS_ADMIN_ID &lt;&lt; adminID Q_UINT32 adminID; // The ID of the admin<p>
Note: This answer is also automatically sent to a new connected client, so that he can see if he is the admin or not. It will also be sent to all connected clients when a new admin is set (see REQ_ADMIN_CHANGE).<p>
<ul>
<li>QByteArray &lt;&lt; static_cast&lt;Q_UINT32&gt;( REQ_ADMIN_CHANGE ) &lt;&lt; new_admin Q_UINT32 new_admin; // the ID of the new admin, or 0 for no admin</li></ul>
<p>
When the server receives this message, it sets the admin to the new ID. If no client with that ID exists, nothing happens. With new_admin == 0 no client is a admin. ONLY THE ADMIN ITSELF CAN USE THIS MESSAGE!<p>
Note: The server sends a ANS_ADMIN_ID message to every connected client.<p>
<ul>
<li>QByteArray &lt;&lt; static_cast&lt;Q_UINT32&gt;( REQ_REMOVE_CLIENT ) &lt;&lt; client_list QValueList &lt;Q_UINT32&gt; client_list; // The list of clients to be removed</li></ul>
<p>
When the server receives this message, it removes the clients with the ids stored in client_list, disconnecting the connection to them. ONLY THE ADMIN CAN USE THIS MESSAGE!<p>
Note: If one of the clients is the admin himself, he will also be deleted. Another client (if any left) will become the new admin.<p>
<ul>
<li>QByteArray &lt;&lt; static_cast&lt;Q_UINT32&gt;( REQ_MAX_NUM_CLIENTS ) &lt;&lt; maximum_clients Q_INT32 maximum_clients; // The maximum of clients connected, or infinite if -1</li></ul>
<p>
When the server receives this message, it limits the number of clients to the number given, or sets it unlimited for maximum_clients == -1. ONLY THE ADMIN CAN USE THIS MESSAGE!<p>
Note: If there are already more clients, they are not affected. It only prevents new Clients to be added. To assure this limit, remove clients afterwards (REQ_REMOVE_CLIENT)<p>
<ul>
<li>QByteArray &lt;&lt; static_cast&lt;Q_UINT32&gt;( REQ_CLIENT_LIST )</li></ul>
<p>
When the server receives this message, it answers by sending a list of IDs of all the clients that are connected at the moment. So it sends the following message to the asking client: QByteArray &lt;&lt; static_cast&lt;Q_UINT32&gt;( ANS_CLIENT_LIST ) &lt;&lt; clientList QValueList &lt;Q_UINT32&gt; clientList; // The IDs of the connected clients<p>
Note: This message is also sent to every new connected client, so that he knows the other clients.<p>
There are two more messages that are sent from the server to the every client automatically when a new client connects or a connection to a client is lost:<p>
QByteArray &lt;&lt; static_cast&lt;Q_UINT32&gt;( EVNT_CLIENT_CONNECTED ) &lt;&lt; clientID; Q_UINT32 clientID; // the ID of the new connected client<p>
QByteArray &lt;&lt; static_cast&lt;Q_UINT32&gt;( EVNT_CLIENT_DISCONNECTED ) &lt;&lt; clientID; Q_UINT32 clientID; // the ID of the client that lost the connection Q_UINT8 broken; // 1 if the network connection was closed, 0 if it was disconnected on purpose<p>
<dl class="author" compact><dt><b>Author:</b></dt><dd>Andreas Beckermann &lt;<a href="mailto:b_mann@gmx.de">b_mann@gmx.de</a>&gt;, Burkhard Lehner &lt;<a href="mailto:Burkhard.Lehner@gmx.de">Burkhard.Lehner@gmx.de</a>&gt; </dd></dl>
<dl class="version" compact><dt><b>Version:</b></dt><dd></dd></dl>
<dl class="rcs" compact><dt><b>Id</b></dt><dd><a class="el" href="kmessageserver_8h-source.html">kmessageserver.h</a> 465369 2005-09-29 14:33:08Z mueller </dd></dl>

<p>Definition at line <a class="el" href="kmessageserver_8h-source.html#l00175">175</a> of file <a class="el" href="kmessageserver_8h-source.html">kmessageserver.h</a>.</p>
<table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Public Types</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">enum &nbsp;</td><td class="memItemRight" valign="bottom">{ <br>
&nbsp;&nbsp;<b>REQ_BROADCAST</b> =  1, 
<b>REQ_FORWARD</b>, 
<b>REQ_CLIENT_ID</b>, 
<b>REQ_ADMIN_ID</b>, 
<br>
&nbsp;&nbsp;<b>REQ_ADMIN_CHANGE</b>, 
<b>REQ_REMOVE_CLIENT</b>, 
<b>REQ_MAX_NUM_CLIENTS</b>, 
<b>REQ_CLIENT_LIST</b>, 
<br>
&nbsp;&nbsp;<b>REQ_MAX_REQ</b> =  0xffff
<br>
 }</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">enum &nbsp;</td><td class="memItemRight" valign="bottom">{ <br>
&nbsp;&nbsp;<b>MSG_BROADCAST</b> =  101, 
<b>MSG_FORWARD</b>, 
<b>ANS_CLIENT_ID</b>, 
<b>ANS_ADMIN_ID</b>, 
<br>
&nbsp;&nbsp;<b>ANS_CLIENT_LIST</b>, 
<b>EVNT_CLIENT_CONNECTED</b>, 
<b>EVNT_CLIENT_DISCONNECTED</b>, 
<b>EVNT_MAX_EVNT</b> =  0xffff
<br>
 }</td></tr>

<tr><td colspan="2"><br><h2>Public Slots</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classKMessageServer.html#35a70cc866b4dd7b701441c7bf5e74a6">addClient</a> (<a class="el" href="classKMessageIO.html">KMessageIO</a> *)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classKMessageServer.html#0121eb7290ca87fe029ef7ebc07987d8">removeClient</a> (<a class="el" href="classKMessageIO.html">KMessageIO</a> *io, bool broken)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classKMessageServer.html#83711f659add36cae0ce2c961f3af1bb">deleteClients</a> ()</td></tr>

<tr><td colspan="2"><br><h2>Signals</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classKMessageServer.html#05d103426a6e7b7d683f79ac68362bdd">clientConnected</a> (<a class="el" href="classKMessageIO.html">KMessageIO</a> *client)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classKMessageServer.html#788b84030f15dfce1593ba24cb056403">connectionLost</a> (<a class="el" href="classKMessageIO.html">KMessageIO</a> *client)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classKMessageServer.html#c73152a36f36c614087292b0ff0ffac7">messageReceived</a> (const QByteArray &amp;data, Q_UINT32 clientID, bool &amp;unknown)</td></tr>

<tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classKMessageServer.html#56f63c95fa8f210cb55069fa77605371">KMessageServer</a> (Q_UINT16 cookie=42, QObject *parent=0)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">virtual void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classKMessageServer.html#2423ce5bd2becb27722796b9b694a0a4">Debug</a> ()</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">bool&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classKMessageServer.html#0501651eb0590202bbd2663f8646a238">initNetwork</a> (Q_UINT16 port=0)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">Q_UINT16&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classKMessageServer.html#8aba1f9027f3c6bdcdf81b368207352d">serverPort</a> () const </td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classKMessageServer.html#adf678b44467ef8fde65c471dc5fae67">stopNetwork</a> ()</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">bool&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classKMessageServer.html#6c7399aee9ba1cd35c9148356bdae52c">isOfferingConnections</a> () const </td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classKMessageServer.html#0bc8ffb9f20f1357ded5a6ee7e303b55">setMaxClients</a> (int maxnumber)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classKMessageServer.html#f329440ac1118cb22ad77994a4ca6810">maxClients</a> () const </td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classKMessageServer.html#775eaba50f3fee9d8b0b15377a501b47">clientCount</a> () const </td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">QValueList&lt; Q_UINT32 &gt;&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classKMessageServer.html#ced480c16f0761bfdf9dfa4616b2dc2f">clientIDs</a> () const </td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="classKMessageIO.html">KMessageIO</a> *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classKMessageServer.html#4116ad177959708b8693103b0e2857dc">findClient</a> (Q_UINT32 no) const </td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">Q_UINT32&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classKMessageServer.html#7f1d82c9f920c382ef535e218c581e00">adminID</a> () const </td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classKMessageServer.html#cb43463bb81a605dabb66c589123f8e9">setAdmin</a> (Q_UINT32 adminID)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">virtual void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classKMessageServer.html#9b43ca198bf40df882ff54065b8876ad">broadcastMessage</a> (const QByteArray &amp;msg)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">virtual void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classKMessageServer.html#5817f74b81a03e8fdd3cc24eb5c37bb7">sendMessage</a> (Q_UINT32 id, const QByteArray &amp;msg)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">virtual void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classKMessageServer.html#a230241482967cc348f01e2699b7ac47">sendMessage</a> (const QValueList&lt; Q_UINT32 &gt; &amp;ids, const QByteArray &amp;msg)</td></tr>

<tr><td colspan="2"><br><h2>Protected Slots</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">virtual void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classKMessageServer.html#2430a7bb860e22953f74487730e713bc">getReceivedMessage</a> (const QByteArray &amp;msg)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">virtual void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classKMessageServer.html#4ca5b488b041c7bb79207d09042299c4">processOneMessage</a> ()</td></tr>

<tr><td colspan="2"><br><h2>Protected Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">Q_UINT32&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classKMessageServer.html#5a75331faf6f4b94c1e5eb7700960826">uniqueClientNumber</a> () const </td></tr>

</table>
<hr><h2>Member Enumeration Documentation</h2>
<a class="anchor" name="3275a2dae8023b3ec63bf1d808eae2d7"></a><!-- doxytag: member="KMessageServer::@1" ref="3275a2dae8023b3ec63bf1d808eae2d7" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">anonymous enum          </td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
MessageIDs for messages from a client to the message server. 
<p>

<p>Definition at line <a class="el" href="kmessageserver_8h-source.html#l00183">183</a> of file <a class="el" href="kmessageserver_8h-source.html">kmessageserver.h</a>.</p>

</div>
</div><p>
<a class="anchor" name="6f541716a1539203574ca1967c553508"></a><!-- doxytag: member="KMessageServer::@2" ref="6f541716a1539203574ca1967c553508" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">anonymous enum          </td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
MessageIDs for messages from the message server to a client. 
<p>

<p>Definition at line <a class="el" href="kmessageserver_8h-source.html#l00197">197</a> of file <a class="el" href="kmessageserver_8h-source.html">kmessageserver.h</a>.</p>

</div>
</div><p>
<hr><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" name="56f63c95fa8f210cb55069fa77605371"></a><!-- doxytag: member="KMessageServer::KMessageServer" ref="56f63c95fa8f210cb55069fa77605371" args="(Q_UINT16 cookie=42, QObject *parent=0)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">KMessageServer::KMessageServer           </td>
          <td>(</td>
          <td class="paramtype">Q_UINT16&nbsp;</td>
          <td class="paramname"> <em>cookie</em> = <code>42</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">QObject *&nbsp;</td>
          <td class="paramname"> <em>parent</em> = <code>0</code></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Create a <a class="el" href="classKGameNetwork.html" title="The KGameNetwork class is the KGame class with network support.">KGameNetwork</a> object. 
<p>

<p>Definition at line <a class="el" href="kmessageserver_8cpp-source.html#l00089">89</a> of file <a class="el" href="kmessageserver_8cpp-source.html">kmessageserver.cpp</a>.</p>

</div>
</div><p>
<hr><h2>Member Function Documentation</h2>
<a class="anchor" name="2423ce5bd2becb27722796b9b694a0a4"></a><!-- doxytag: member="KMessageServer::Debug" ref="2423ce5bd2becb27722796b9b694a0a4" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void KMessageServer::Debug           </td>
          <td>(</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"><code> [virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Gives debug output of the game status. 
<p>

<p>Definition at line <a class="el" href="kmessageserver_8cpp-source.html#l00507">507</a> of file <a class="el" href="kmessageserver_8cpp-source.html">kmessageserver.cpp</a>.</p>

</div>
</div><p>
<a class="anchor" name="0501651eb0590202bbd2663f8646a238"></a><!-- doxytag: member="KMessageServer::initNetwork" ref="0501651eb0590202bbd2663f8646a238" args="(Q_UINT16 port=0)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool KMessageServer::initNetwork           </td>
          <td>(</td>
          <td class="paramtype">Q_UINT16&nbsp;</td>
          <td class="paramname"> <em>port</em> = <code>0</code>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Starts the Communication server to listen for incoming TCP/IP connections. 
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>port</em>&nbsp;</td><td>The port on which the service is offered, or 0 to let the system pick a free port </td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>true if it worked </dd></dl>

<p>Definition at line <a class="el" href="kmessageserver_8cpp-source.html#l00118">118</a> of file <a class="el" href="kmessageserver_8cpp-source.html">kmessageserver.cpp</a>.</p>

</div>
</div><p>
<a class="anchor" name="8aba1f9027f3c6bdcdf81b368207352d"></a><!-- doxytag: member="KMessageServer::serverPort" ref="8aba1f9027f3c6bdcdf81b368207352d" args="() const " -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">Q_UINT16 KMessageServer::serverPort           </td>
          <td>(</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"> const</td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Returns the TCP/IP port number we are listening to for incoming connections. 
<p>
(This has to be known by other clients so that they can connect to us. It's especially necessary if you used 0 as port number in <a class="el" href="classKMessageServer.html#0501651eb0590202bbd2663f8646a238" title="Starts the Communication server to listen for incoming TCP/IP connections.">initNetwork()</a>. <dl class="return" compact><dt><b>Returns:</b></dt><dd>the port number </dd></dl>

<p>Definition at line <a class="el" href="kmessageserver_8cpp-source.html#l00146">146</a> of file <a class="el" href="kmessageserver_8cpp-source.html">kmessageserver.cpp</a>.</p>

</div>
</div><p>
<a class="anchor" name="adf678b44467ef8fde65c471dc5fae67"></a><!-- doxytag: member="KMessageServer::stopNetwork" ref="adf678b44467ef8fde65c471dc5fae67" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void KMessageServer::stopNetwork           </td>
          <td>(</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Stops listening for connections. 
<p>
The already running connections are not affected. To listen for connections again call initNetwork again. 
<p>Definition at line <a class="el" href="kmessageserver_8cpp-source.html#l00154">154</a> of file <a class="el" href="kmessageserver_8cpp-source.html">kmessageserver.cpp</a>.</p>

</div>
</div><p>
<a class="anchor" name="6c7399aee9ba1cd35c9148356bdae52c"></a><!-- doxytag: member="KMessageServer::isOfferingConnections" ref="6c7399aee9ba1cd35c9148356bdae52c" args="() const " -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool KMessageServer::isOfferingConnections           </td>
          <td>(</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"> const</td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Are we still offer offering server connections? 
<p>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>true, if we are still listening to connections requests </dd></dl>

<p>Definition at line <a class="el" href="kmessageserver_8cpp-source.html#l00163">163</a> of file <a class="el" href="kmessageserver_8cpp-source.html">kmessageserver.cpp</a>.</p>

</div>
</div><p>
<a class="anchor" name="35a70cc866b4dd7b701441c7bf5e74a6"></a><!-- doxytag: member="KMessageServer::addClient" ref="35a70cc866b4dd7b701441c7bf5e74a6" args="(KMessageIO *)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void KMessageServer::addClient           </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classKMessageIO.html">KMessageIO</a> *&nbsp;</td>
          <td class="paramname"> <em>client</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"><code> [slot]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Adds a new <a class="el" href="classKMessageIO.html">KMessageIO</a> object to the communication server. 
<p>
This "client" gets a unique ID.<p>
This slot method is automatically called for any incoming TCP/IP connection. You can use it to add other types of connections, e.g. local connections (<a class="el" href="classKMessageDirect.html" title="This class implements the message communication using function calls directly.">KMessageDirect</a>) to the server manually.<p>
NOTE: The <a class="el" href="classKMessageIO.html">KMessageIO</a> object gets owned by the <a class="el" href="classKMessageServer.html" title="A server for message sending and broadcasting, using TCP/IP connections.">KMessageServer</a>, so don't delete or manipulate it afterwards. It is automatically deleted when the connection is broken or the communication server is deleted. So, add a <a class="el" href="classKMessageIO.html">KMessageIO</a> object to just ONE <a class="el" href="classKMessageServer.html" title="A server for message sending and broadcasting, using TCP/IP connections.">KMessageServer</a>. 
<p>Definition at line <a class="el" href="kmessageserver_8cpp-source.html#l00170">170</a> of file <a class="el" href="kmessageserver_8cpp-source.html">kmessageserver.cpp</a>.</p>

</div>
</div><p>
<a class="anchor" name="0121eb7290ca87fe029ef7ebc07987d8"></a><!-- doxytag: member="KMessageServer::removeClient" ref="0121eb7290ca87fe029ef7ebc07987d8" args="(KMessageIO *io, bool broken)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void KMessageServer::removeClient           </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classKMessageIO.html">KMessageIO</a> *&nbsp;</td>
          <td class="paramname"> <em>io</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&nbsp;</td>
          <td class="paramname"> <em>broken</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td width="100%"><code> [slot]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Removes the <a class="el" href="classKMessageIO.html" title="This abstract base class represents one end of a message connections between two...">KMessageIO</a> object from the client list and deletes it. 
<p>
This destroys the connection, if it already was up. Does NOT emit connectionLost. Sends an info message to the other clients, that contains the ID of the removed client and the value of the parameter broken.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>io</em>&nbsp;</td><td>the object to delete and to remove from the client list </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>broken</em>&nbsp;</td><td>true if the client has lost connection Mostly used internally. You will probably not need this. </td></tr>
  </table>
</dl>

<p>Definition at line <a class="el" href="kmessageserver_8cpp-source.html#l00223">223</a> of file <a class="el" href="kmessageserver_8cpp-source.html">kmessageserver.cpp</a>.</p>

</div>
</div><p>
<a class="anchor" name="83711f659add36cae0ce2c961f3af1bb"></a><!-- doxytag: member="KMessageServer::deleteClients" ref="83711f659add36cae0ce2c961f3af1bb" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void KMessageServer::deleteClients           </td>
          <td>(</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"><code> [slot]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Deletes all connections to the clients. 
<p>

<p>Definition at line <a class="el" href="kmessageserver_8cpp-source.html#l00247">247</a> of file <a class="el" href="kmessageserver_8cpp-source.html">kmessageserver.cpp</a>.</p>

</div>
</div><p>
<a class="anchor" name="0bc8ffb9f20f1357ded5a6ee7e303b55"></a><!-- doxytag: member="KMessageServer::setMaxClients" ref="0bc8ffb9f20f1357ded5a6ee7e303b55" args="(int maxnumber)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void KMessageServer::setMaxClients           </td>
          <td>(</td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>maxnumber</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
sets the maximum number of clients which can connect. 
<p>
If this number is reached, no more clients can be added. Setting this number to -1 means unlimited number of clients.<p>
NOTE: Existing connections are not affected. So, clientCount &gt; maxClients is possible, if there were already more clients than allowed before reducing this value.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>maxnumber</em>&nbsp;</td><td>the number of clients </td></tr>
  </table>
</dl>

<p>Definition at line <a class="el" href="kmessageserver_8cpp-source.html#l00268">268</a> of file <a class="el" href="kmessageserver_8cpp-source.html">kmessageserver.cpp</a>.</p>

</div>
</div><p>
<a class="anchor" name="f329440ac1118cb22ad77994a4ca6810"></a><!-- doxytag: member="KMessageServer::maxClients" ref="f329440ac1118cb22ad77994a4ca6810" args="() const " -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int KMessageServer::maxClients           </td>
          <td>(</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"> const</td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
returns the maximum number of clients 
<p>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>the number of clients </dd></dl>

<p>Definition at line <a class="el" href="kmessageserver_8cpp-source.html#l00273">273</a> of file <a class="el" href="kmessageserver_8cpp-source.html">kmessageserver.cpp</a>.</p>

</div>
</div><p>
<a class="anchor" name="775eaba50f3fee9d8b0b15377a501b47"></a><!-- doxytag: member="KMessageServer::clientCount" ref="775eaba50f3fee9d8b0b15377a501b47" args="() const " -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int KMessageServer::clientCount           </td>
          <td>(</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"> const</td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
returns the current number of connected clients. 
<p>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>the number of clients </dd></dl>

<p>Definition at line <a class="el" href="kmessageserver_8cpp-source.html#l00278">278</a> of file <a class="el" href="kmessageserver_8cpp-source.html">kmessageserver.cpp</a>.</p>

</div>
</div><p>
<a class="anchor" name="ced480c16f0761bfdf9dfa4616b2dc2f"></a><!-- doxytag: member="KMessageServer::clientIDs" ref="ced480c16f0761bfdf9dfa4616b2dc2f" args="() const " -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">QValueList&lt; Q_UINT32 &gt; KMessageServer::clientIDs           </td>
          <td>(</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"> const</td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
returns a list of the unique IDs of all clients. 
<p>

<p>Definition at line <a class="el" href="kmessageserver_8cpp-source.html#l00283">283</a> of file <a class="el" href="kmessageserver_8cpp-source.html">kmessageserver.cpp</a>.</p>

</div>
</div><p>
<a class="anchor" name="4116ad177959708b8693103b0e2857dc"></a><!-- doxytag: member="KMessageServer::findClient" ref="4116ad177959708b8693103b0e2857dc" args="(Q_UINT32 no) const " -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classKMessageIO.html">KMessageIO</a> * KMessageServer::findClient           </td>
          <td>(</td>
          <td class="paramtype">Q_UINT32&nbsp;</td>
          <td class="paramname"> <em>no</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"> const</td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Find the <a class="el" href="classKMessageIO.html">KMessageIO</a> object to the given client number. 
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>no</em>&nbsp;</td><td>the client number to look for, or 0 to look for the admin </td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>address of the client, or 0 if no client with that number exists </dd></dl>

<p>Definition at line <a class="el" href="kmessageserver_8cpp-source.html#l00291">291</a> of file <a class="el" href="kmessageserver_8cpp-source.html">kmessageserver.cpp</a>.</p>

</div>
</div><p>
<a class="anchor" name="7f1d82c9f920c382ef535e218c581e00"></a><!-- doxytag: member="KMessageServer::adminID" ref="7f1d82c9f920c382ef535e218c581e00" args="() const " -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">Q_UINT32 KMessageServer::adminID           </td>
          <td>(</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"> const</td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Returns the clientID of the admin, if there is a admin, 0 otherwise. 
<p>
NOTE: Most often you don't need to know that id, since you can use clientID 0 to specify the admin. 
<p>Definition at line <a class="el" href="kmessageserver_8cpp-source.html#l00306">306</a> of file <a class="el" href="kmessageserver_8cpp-source.html">kmessageserver.cpp</a>.</p>

</div>
</div><p>
<a class="anchor" name="cb43463bb81a605dabb66c589123f8e9"></a><!-- doxytag: member="KMessageServer::setAdmin" ref="cb43463bb81a605dabb66c589123f8e9" args="(Q_UINT32 adminID)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void KMessageServer::setAdmin           </td>
          <td>(</td>
          <td class="paramtype">Q_UINT32&nbsp;</td>
          <td class="paramname"> <em>adminID</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Sets the admin to a new client with the given ID. 
<p>
The old admin (if existed) and the new admin will get the ANS_ADMIN message. If you use 0 as new adminID, no client will be admin. 
<p>Definition at line <a class="el" href="kmessageserver_8cpp-source.html#l00311">311</a> of file <a class="el" href="kmessageserver_8cpp-source.html">kmessageserver.cpp</a>.</p>

</div>
</div><p>
<a class="anchor" name="9b43ca198bf40df882ff54065b8876ad"></a><!-- doxytag: member="KMessageServer::broadcastMessage" ref="9b43ca198bf40df882ff54065b8876ad" args="(const QByteArray &amp;msg)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void KMessageServer::broadcastMessage           </td>
          <td>(</td>
          <td class="paramtype">const QByteArray &amp;&nbsp;</td>
          <td class="paramname"> <em>msg</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"><code> [virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Sends a message to all connected clients. 
<p>
The message is NOT translated in any way. This method calls <a class="el" href="classKMessageIO.html#595c09956ca3135e868fa9d47fe22958">KMessageIO::send</a> for every client added. 
<p>Definition at line <a class="el" href="kmessageserver_8cpp-source.html#l00342">342</a> of file <a class="el" href="kmessageserver_8cpp-source.html">kmessageserver.cpp</a>.</p>

</div>
</div><p>
<a class="anchor" name="5817f74b81a03e8fdd3cc24eb5c37bb7"></a><!-- doxytag: member="KMessageServer::sendMessage" ref="5817f74b81a03e8fdd3cc24eb5c37bb7" args="(Q_UINT32 id, const QByteArray &amp;msg)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void KMessageServer::sendMessage           </td>
          <td>(</td>
          <td class="paramtype">Q_UINT32&nbsp;</td>
          <td class="paramname"> <em>id</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const QByteArray &amp;&nbsp;</td>
          <td class="paramname"> <em>msg</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td width="100%"><code> [virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Sends a message to a single client with the given ID. 
<p>
The message is NOT translated in any way. If no client with the given id exists, nothing is done. This is just a convenience method. You could also call <a class="el" href="classKMessageServer.html#4116ad177959708b8693103b0e2857dc">findClient</a> (id)-&gt;send(msg) manually, but this method checks for errors. 
<p>Definition at line <a class="el" href="kmessageserver_8cpp-source.html#l00348">348</a> of file <a class="el" href="kmessageserver_8cpp-source.html">kmessageserver.cpp</a>.</p>

</div>
</div><p>
<a class="anchor" name="a230241482967cc348f01e2699b7ac47"></a><!-- doxytag: member="KMessageServer::sendMessage" ref="a230241482967cc348f01e2699b7ac47" args="(const QValueList&lt; Q_UINT32 &gt; &amp;ids, const QByteArray &amp;msg)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void KMessageServer::sendMessage           </td>
          <td>(</td>
          <td class="paramtype">const QValueList&lt; Q_UINT32 &gt; &amp;&nbsp;</td>
          <td class="paramname"> <em>ids</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const QByteArray &amp;&nbsp;</td>
          <td class="paramname"> <em>msg</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td width="100%"><code> [virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Sends a message to a list of clients. 
<p>
Their ID is given in ids. If a client id is given more than once in the list, the message is also sent several times to that client. This is just a convenience method. You could also iterate over the list of IDs. 
<p>Definition at line <a class="el" href="kmessageserver_8cpp-source.html#l00355">355</a> of file <a class="el" href="kmessageserver_8cpp-source.html">kmessageserver.cpp</a>.</p>

</div>
</div><p>
<a class="anchor" name="2430a7bb860e22953f74487730e713bc"></a><!-- doxytag: member="KMessageServer::getReceivedMessage" ref="2430a7bb860e22953f74487730e713bc" args="(const QByteArray &amp;msg)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void KMessageServer::getReceivedMessage           </td>
          <td>(</td>
          <td class="paramtype">const QByteArray &amp;&nbsp;</td>
          <td class="paramname"> <em>msg</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"><code> [protected, virtual, slot]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
This slot receives all the messages from the <a class="el" href="classKMessageIO.html#c2925ec4f163a91f15b037dcd9dc93a2">KMessageIO::received</a> signals. 
<p>
It stores the messages in a queue. The messages are later taken out of the queue by <a class="el" href="classKMessageServer.html#2430a7bb860e22953f74487730e713bc">getReceivedMessage</a>.<p>
NOTE: It is important that this slot may only be called from the signal <a class="el" href="classKMessageIO.html#c2925ec4f163a91f15b037dcd9dc93a2">KMessageIO::received</a>, since the sender() object is used to find out the client that sent the message! 
<p>Definition at line <a class="el" href="kmessageserver_8cpp-source.html#l00361">361</a> of file <a class="el" href="kmessageserver_8cpp-source.html">kmessageserver.cpp</a>.</p>

</div>
</div><p>
<a class="anchor" name="4ca5b488b041c7bb79207d09042299c4"></a><!-- doxytag: member="KMessageServer::processOneMessage" ref="4ca5b488b041c7bb79207d09042299c4" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void KMessageServer::processOneMessage           </td>
          <td>(</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"><code> [protected, virtual, slot]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
This slot is called whenever there are elements in the message queue. 
<p>
This queue is filled by <a class="el" href="classKMessageServer.html#2430a7bb860e22953f74487730e713bc">getReceivedMessage</a>. This slot takes one message out of the queue and analyses processes it, if it recognizes it. (See message types in the description of the class.) After that, the signal <a class="el" href="classKMessageServer.html#c73152a36f36c614087292b0ff0ffac7">messageReceived</a> is emitted. Connect to that signal if you want to process other types of messages. 
<p>Definition at line <a class="el" href="kmessageserver_8cpp-source.html#l00382">382</a> of file <a class="el" href="kmessageserver_8cpp-source.html">kmessageserver.cpp</a>.</p>

</div>
</div><p>
<a class="anchor" name="05d103426a6e7b7d683f79ac68362bdd"></a><!-- doxytag: member="KMessageServer::clientConnected" ref="05d103426a6e7b7d683f79ac68362bdd" args="(KMessageIO *client)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void KMessageServer::clientConnected           </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classKMessageIO.html">KMessageIO</a> *&nbsp;</td>
          <td class="paramname"> <em>client</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"><code> [signal]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
A new client connected to the game. 
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>client</em>&nbsp;</td><td>the client object that connected </td></tr>
  </table>
</dl>

</div>
</div><p>
<a class="anchor" name="788b84030f15dfce1593ba24cb056403"></a><!-- doxytag: member="KMessageServer::connectionLost" ref="788b84030f15dfce1593ba24cb056403" args="(KMessageIO *client)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void KMessageServer::connectionLost           </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classKMessageIO.html">KMessageIO</a> *&nbsp;</td>
          <td class="paramname"> <em>client</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"><code> [signal]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
A network connection got broken. 
<p>
Note that the client will automatically get deleted after this signal is emitted. The signal is not emitted when the client was removed regularly.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>client</em>&nbsp;</td><td>the client which left the game </td></tr>
  </table>
</dl>

</div>
</div><p>
<a class="anchor" name="c73152a36f36c614087292b0ff0ffac7"></a><!-- doxytag: member="KMessageServer::messageReceived" ref="c73152a36f36c614087292b0ff0ffac7" args="(const QByteArray &amp;data, Q_UINT32 clientID, bool &amp;unknown)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void KMessageServer::messageReceived           </td>
          <td>(</td>
          <td class="paramtype">const QByteArray &amp;&nbsp;</td>
          <td class="paramname"> <em>data</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Q_UINT32&nbsp;</td>
          <td class="paramname"> <em>clientID</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool &amp;&nbsp;</td>
          <td class="paramname"> <em>unknown</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td width="100%"><code> [signal]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
This signal is always emitted when a message from a client is received. 
<p>
You can use this signal to extend the communication server without subclassing. Just connect to this signal and analyse the message, if unknown is true. If you recognize a message and process it, set unknown to false, otherwise a warning message is printed.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>data</em>&nbsp;</td><td>the message data </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>clientID</em>&nbsp;</td><td>the ID of the <a class="el" href="classKMessageIO.html" title="This abstract base class represents one end of a message connections between two...">KMessageIO</a> object that received the message </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>unknown</em>&nbsp;</td><td>true, if the message type is not known by the <a class="el" href="classKMessageServer.html" title="A server for message sending and broadcasting, using TCP/IP connections.">KMessageServer</a> </td></tr>
  </table>
</dl>

</div>
</div><p>
<a class="anchor" name="5a75331faf6f4b94c1e5eb7700960826"></a><!-- doxytag: member="KMessageServer::uniqueClientNumber" ref="5a75331faf6f4b94c1e5eb7700960826" args="() const " -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">Q_UINT32 KMessageServer::uniqueClientNumber           </td>
          <td>(</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"> const<code> [protected]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>A unique number which can be used as the id of a <a class="el" href="classKMessageIO.html">KMessageIO</a>. It is incremented after every call so if you need the id twice you have to save it anywhere. It's currently used to initialize newly connected clints only. </dd></dl>

<p>Definition at line <a class="el" href="kmessageserver_8cpp-source.html#l00335">335</a> of file <a class="el" href="kmessageserver_8cpp-source.html">kmessageserver.cpp</a>.</p>

</div>
</div><p>
<hr>The documentation for this class was generated from the following files:<ul>
<li><a class="el" href="kmessageserver_8h-source.html">kmessageserver.h</a><li><a class="el" href="kmessageserver_8cpp-source.html">kmessageserver.cpp</a></ul>
</div>
    </div></div>


      </td>
  </tr>
  <tr>
    <td valign="top" id="leftmenu" width="25%">
      <a name="navigation"></a>
      <div class="menu_box"><h2>libkdegames</h2>
<div class="nav_list">
<ul><li><a href="index.html">Main Page</a></li><li><a href="hierarchy.html">Class Hierarchy</a></li><li><a href="classes.html">Alphabetical List</a></li><li><a href="annotated.html">Class List</a></li><li><a href="files.html">File List</a></li><li><a href="functions.html">Class Members</a></li><li><a href="pages.html">Related Pages</a></li></ul>
<!--
<h2>Class Picker</h2>
<div style="text-align: center;">
<form name="guideform">
<select name="guidelinks" style="width:100%;" onChange="window.location=document.guideform.guidelinks.options[document.guideform.guidelinks.selectedIndex].value">
<option value="annotated.html">-- Choose --</option>
  <option value="classKCanvasRootPixmap.html">kcanvasrootpixmap</option>,  <option value="classKCardDialog.html">kcarddialog</option>,  <option value="classKChat.html">kchat</option>,  <option value="classKChatBase.html">kchatbase</option>,  <option value="classKChatBaseText.html">kchatbasetext</option>,  <option value="classKExtHighscore_1_1Item.html">kexthighscore::item</option>,  <option value="classKExtHighscore_1_1ItemArray.html">kexthighscore::itemarray</option>,  <option value="classKExtHighscore_1_1Manager.html">kexthighscore::manager</option>,  <option value="classKExtHighscore_1_1MultiplayerScores.html">kexthighscore::multiplayerscores</option>,  <option value="classKExtHighscore_1_1Score.html">kexthighscore::score</option>,  <option value="classKGame.html">kgame</option>,  <option value="classKGameChat.html">kgamechat</option>,  <option value="classKGameComputerIO.html">kgamecomputerio</option>,  <option value="classKGameConnectDialog.html">kgameconnectdialog</option>,  <option value="classKGameDialog.html">kgamedialog</option>,  <option value="classKGameDialogChatConfig.html">kgamedialogchatconfig</option>,  <option value="classKGameDialogConfig.html">kgamedialogconfig</option>,  <option value="classKGameErrorDialog.html">kgameerrordialog</option>,  <option value="classKGameErrorMessageDialog.html">kgameerrormessagedialog</option>,  <option value="classKGameIO.html">kgameio</option>,  <option value="classKGameKeyIO.html">kgamekeyio</option>,  <option value="classKGameLCD.html">kgamelcd</option>,  <option value="classKGameLCDClock.html">kgamelcdclock</option>,  <option value="classKGameLCDList.html">kgamelcdlist</option>,  <option value="classKGameMisc.html">kgamemisc</option>,  <option value="classKGameMouseIO.html">kgamemouseio</option>,  <option value="classKGameNetwork.html">kgamenetwork</option>,  <option value="classKGameProcess.html">kgameprocess</option>,  <option value="classKGameProcessIO.html">kgameprocessio</option>,  <option value="classKGameProgress.html">kgameprogress</option>,  <option value="classKGameProperty.html">kgameproperty</option>,  <option value="classKGamePropertyBase.html">kgamepropertybase</option>,  <option value="classKGamePropertyHandler.html">kgamepropertyhandler</option>,  <option value="classKGameSequence.html">kgamesequence</option>,  <option value="classKGrid2D_1_1Generic.html">kgrid2d::generic</option>,  <option value="classKGrid2D_1_1Hexagonal.html">kgrid2d::hexagonal</option>,  <option value="classKGrid2D_1_1HexagonalBase.html">kgrid2d::hexagonalbase</option>,  <option value="classKGrid2D_1_1Square.html">kgrid2d::square</option>,  <option value="classKGrid2D_1_1SquareBase.html">kgrid2d::squarebase</option>,  <option value="classKHighscore.html">khighscore</option>,  <option value="classKMessageClient.html">kmessageclient</option>,  <option value="classKMessageDirect.html">kmessagedirect</option>,  <option value="classKMessageIO.html">kmessageio</option>,  <option value="classKMessageServer.html">kmessageserver</option>,  <option value="classKMessageServerSocket.html">kmessageserversocket</option>,  <option value="classKMessageSocket.html">kmessagesocket</option>,  <option value="classKPlayer.html">kplayer</option>,  <option value="classKScoreDialog.html">kscoredialog</option>,  <option value="classKStdGameAction.html">kstdgameaction</option>,
</select>
</form>
</div>
-->
</div></div>
<div class="menu_box"><h2>API Dox</h2>
<div class="nav_list">
<ul>
<li><a href="../../libkdegames/html/index.html">libkdegames</a></li>
</ul></div></div>


        </td>
</tr>
</table>

<span class="doNotDisplay">
  <a href="http://www.kde.org/" accesskey="8">KDE Home</a> |
  <a href="http://accessibility.kde.org/" accesskey="9">KDE Accessibility Home</a> |
  <a href="http://www.kde.org/media/accesskeys.php" accesskey="0">Description of Access Keys</a>
</span>


<div style="height: 8px"></div>

<div id="footer">
  <div id="footer_left">
    Maintained by <a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;groo&#116;&#64;kde&#46;or&#x67;">Adriaan de Groot</a>
and
<a href="&#109;a&#105;&#108;&#116;&#111;&#58;w&#105;nter&#64;kde&#46;or&#x67">Allen Winter</a>.
<br/>
    KDE and K Desktop Environment are trademarks of <a href="http://www.kde.org/areas/kde-ev/" title="Homepage of the KDE non-profit Organization">KDE e.V.</a> |
    <a href="http://www.kde.org/contact/impressum.php">Legal</a>
  </div>
  <div id="footer_right"><img src="/media/images/footer_right.png" style="margin: 0px" alt="" /></div>
</div>

<!--
WARNING: DO NOT SEND MAIL TO THE FOLLOWING EMAIL ADDRESS! YOU WILL
BE BLOCKED INSTANTLY AND PERMANENTLY!
<a href="mailto:aaaatrap-425acc3b5374943f@kde.org">Block me</a>
WARNING END
-->

</body>
</html>