aboutsummaryrefslogtreecommitdiff
path: root/cvs/cvsweb.cgi/code/nel/src/net/message.cpp?rev=1.21&content-type=text/x-cvsweb-markup&sortby=date/index.html
diff options
context:
space:
mode:
authorneodarz <neodarz@neodarz.net>2018-08-11 20:21:34 +0200
committerneodarz <neodarz@neodarz.net>2018-08-11 20:21:34 +0200
commit0ea5fc66924303d1bf73ba283a383e2aadee02f2 (patch)
tree2568e71a7ccc44ec23b8bb3f0ff97fb6bf2ed709 /cvs/cvsweb.cgi/code/nel/src/net/message.cpp?rev=1.21&content-type=text/x-cvsweb-markup&sortby=date/index.html
downloadnevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.tar.xz
nevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.zip
Initial commit
Diffstat (limited to 'cvs/cvsweb.cgi/code/nel/src/net/message.cpp?rev=1.21&content-type=text/x-cvsweb-markup&sortby=date/index.html')
-rw-r--r--cvs/cvsweb.cgi/code/nel/src/net/message.cpp?rev=1.21&content-type=text/x-cvsweb-markup&sortby=date/index.html343
1 files changed, 343 insertions, 0 deletions
diff --git a/cvs/cvsweb.cgi/code/nel/src/net/message.cpp?rev=1.21&content-type=text/x-cvsweb-markup&sortby=date/index.html b/cvs/cvsweb.cgi/code/nel/src/net/message.cpp?rev=1.21&content-type=text/x-cvsweb-markup&sortby=date/index.html
new file mode 100644
index 00000000..0f2922b2
--- /dev/null
+++ b/cvs/cvsweb.cgi/code/nel/src/net/message.cpp?rev=1.21&content-type=text/x-cvsweb-markup&sortby=date/index.html
@@ -0,0 +1,343 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML>
+<HEAD><style> A { color:black }</style>
+<!-- hennerik CVSweb $Revision: 1.93 $ -->
+<TITLE>code/nel/src/net/message.cpp - view - 1.21</TITLE></HEAD>
+<BODY BGCOLOR="#eeeeee">
+<table width="100%" border=0 cellspacing=0 cellpadding=1 bgcolor="#aaaaaa"><tr valign=bottom><td><a href="message.cpp?sortby=date"><IMG SRC="http://www.nevrax.org/inc/img/picto-up.gif" ALT="[BACK]" BORDER="0" WIDTH="14" HEIGHT="13"></a> <b>Return to <A HREF="message.cpp?sortby=date">message.cpp</A>
+ CVS log</b> <IMG SRC="http://www.nevrax.org/inc/img/picto-news.gif" ALT="[TXT]" BORDER="0" WIDTH="13" HEIGHT="15"></td><td align=right><IMG SRC="http://www.nevrax.org/inc/img/picto-dir.gif" ALT="[DIR]" BORDER="0" WIDTH="15" HEIGHT="13"> <b>Up to <a href="/cvs/cvsweb.cgi/?sortby=date">Nevrax</a> / <a href="/cvs/cvsweb.cgi/code/?sortby=date">code</a> / <a href="/cvs/cvsweb.cgi/code/nel/?sortby=date">nel</a> / <a href="/cvs/cvsweb.cgi/code/nel/src/?sortby=date">src</a> / <a href="/cvs/cvsweb.cgi/code/nel/src/net/?sortby=date">net</a></b></td></tr></table><HR noshade><table width="100%"><tr><td bgcolor="#ffffff">File: <a href="/cvs/cvsweb.cgi/?sortby=date">Nevrax</a> / <a href="/cvs/cvsweb.cgi/code/?sortby=date">code</a> / <a href="/cvs/cvsweb.cgi/code/nel/?sortby=date">nel</a> / <a href="/cvs/cvsweb.cgi/code/nel/src/?sortby=date">src</a> / <a href="/cvs/cvsweb.cgi/code/nel/src/net/?sortby=date">net</a> / <a href="/cvs/cvsweb.cgi/code/nel/src/net/message.cpp?sortby=date">message.cpp</a>&nbsp;(<A HREF="/cvs/cvsweb.cgi/~checkout~/code/nel/src/net/message.cpp?rev=1.21&amp;sortby=date" target="cvs_checkout" onClick="window.open('/cvs/cvsweb.cgi/~checkout~/code/nel/src/net/message.cpp?rev=1.21','cvs_checkout','resizeable,scrollbars');"><b>download</b></A>)<BR>
+Revision <B>1.21</B>, <i>Wed Jul 10 17:08:24 2002 UTC</i> (2 weeks, 4 days ago) by <i>lecroart</i>
+<BR>Branch: <b>MAIN</b>
+<BR>CVS Tags: <b>HEAD</b><BR>Changes since <b>1.20: +2 -2
+ lines</b><PRE>
+REMOVE: a warning
+</PRE>
+</td></tr></table><HR noshade><PRE>/** \file message.cpp
+ * CMessage class
+ *
+ * $Id: message.cpp,v 1.21 2002/07/10 17:08:24 lecroart Exp $
+ */
+
+/* Copyright, 2000 Nevrax Ltd.
+ *
+ * This file is part of NEVRAX NEL.
+ * NEVRAX NEL is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+
+ * NEVRAX NEL is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with NEVRAX NEL; see the file COPYING. If not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ */
+
+#include &quot;stdnet.h&quot;
+
+#include &quot;nel/net/message.h&quot;
+
+/*#ifdef MESSAGES_PLAIN_TEXT
+#pragma message( &quot;CMessage: compiling messages as plain text&quot; )
+#else
+#pragma message( &quot;CMessage: compiling messages as binary&quot; )
+#endif*/
+
+namespace NLNET
+{
+
+bool CMessage::_DefaultStringMode = false;
+
+
+#define FormatLong 1
+#define FormatShort 0
+
+
+CMessage::CMessage (NLMISC::CStringIdArray &amp;sida, const std::string &amp;name, bool inputStream, TStreamFormat streamformat, uint32 defaultCapacity) :
+ &nbsp; &nbsp; &nbsp; &nbsp;NLMISC::CMemStream (inputStream, false, defaultCapacity),
+ &nbsp; &nbsp; &nbsp; &nbsp;_TypeSet (false), _SIDA (&amp;sida), _HeaderSize(0xFFFFFFFF)
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;init( name, streamformat );
+}
+
+CMessage::CMessage (const std::string &amp;name, bool inputStream, TStreamFormat streamformat, uint32 defaultCapacity) :
+ &nbsp; &nbsp; &nbsp; &nbsp;NLMISC::CMemStream (inputStream, false, defaultCapacity),
+ &nbsp; &nbsp; &nbsp; &nbsp;_TypeSet (false), _SIDA (NULL), _HeaderSize(0xFFFFFFFF)
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;init( name, streamformat );
+}
+
+
+/*
+ * Utility method
+ */
+void CMessage::init( const std::string &amp;name, TStreamFormat streamformat )
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;if ( streamformat == UseDefault )
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;setStringMode( _DefaultStringMode );
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+ &nbsp; &nbsp; &nbsp; &nbsp;else
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;setStringMode( streamformat == String );
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+
+ &nbsp; &nbsp; &nbsp; &nbsp;if (!name.empty())
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;setType (name);
+}
+
+
+CMessage::CMessage (NLMISC::CMemStream &amp;memstr) :
+ &nbsp; &nbsp; &nbsp; &nbsp;_HeaderSize(0xFFFFFFFF)
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;fill (memstr.buffer (), memstr.length ());
+ &nbsp; &nbsp; &nbsp; &nbsp;uint8 LongFormat=2;
+ &nbsp; &nbsp; &nbsp; &nbsp;serial (LongFormat);
+
+ &nbsp; &nbsp; &nbsp; &nbsp;if (LongFormat)
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;std::string name;
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;serial (name);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;setType (name);
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+ &nbsp; &nbsp; &nbsp; &nbsp;else
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;NLMISC::CStringIdArray::TStringId id;
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;serial (id);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;setType (id);
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+}
+
+
+/// Copy constructor
+CMessage::CMessage (const CMessage &amp;other)
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;operator= (other);
+}
+
+/// Assignment operator
+CMessage &amp;CMessage::operator= (const CMessage &amp;other)
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;CMemStream::operator= (other);
+ &nbsp; &nbsp; &nbsp; &nbsp;_TypeSet = other._TypeSet;
+ &nbsp; &nbsp; &nbsp; &nbsp;_SIDA = other._SIDA;
+ &nbsp; &nbsp; &nbsp; &nbsp;TypeHasAnId = other.TypeHasAnId;
+ &nbsp; &nbsp; &nbsp; &nbsp;TypeHasAName = other.TypeHasAName;
+ &nbsp; &nbsp; &nbsp; &nbsp;_Name = other._Name;
+ &nbsp; &nbsp; &nbsp; &nbsp;_Id = other._Id;
+ &nbsp; &nbsp; &nbsp; &nbsp;_HeaderSize = other._HeaderSize;
+ &nbsp; &nbsp; &nbsp; &nbsp;return *this;
+
+}
+
+/// Sets the message type as a number (in range 0..32767) and put it in the buffer if we are in writing mode
+void CMessage::setType (NLMISC::CStringIdArray::TStringId id)
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;// PATCH: the id system is not available
+ &nbsp; &nbsp; &nbsp; &nbsp;nlstop;
+
+ &nbsp; &nbsp; &nbsp; &nbsp;// check if we already do a setType ()
+ &nbsp; &nbsp; &nbsp; &nbsp;nlassert (!_TypeSet);
+ &nbsp; &nbsp; &nbsp; &nbsp;// don't accept negative value
+ &nbsp; &nbsp; &nbsp; &nbsp;nlassert (id &gt;= 0 &amp;&amp; id &lt; pow(2, sizeof (NLMISC::CStringIdArray::TStringId)*8));
+
+ &nbsp; &nbsp; &nbsp; &nbsp;_Id = id;
+ &nbsp; &nbsp; &nbsp; &nbsp;TypeHasAnId = true;
+ &nbsp; &nbsp; &nbsp; &nbsp;TypeHasAName = false;
+
+ &nbsp; &nbsp; &nbsp; &nbsp;if (!isReading ())
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// check if they don't already serial some stuffs
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nlassert (length () == 0);
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;uint8 format = FormatLong | (_StringMode &lt;&lt; 1);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nlinfo( &quot;OUT format = %hu&quot;, (uint16)format );
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// Force binary mode for header
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;bool msgmode = _StringMode;
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_StringMode = false;
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// debug features, we number all packet to be sure that they are all sent and received
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// \todo remove this debug feature when ok
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// this value will be fill after in the callback function
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;uint32 zeroValue = 123;
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;serial (zeroValue);
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;serial (format);
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// End of binary header
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_StringMode = msgmode;
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;serial (id);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_HeaderSize = getPos ();
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+ &nbsp; &nbsp; &nbsp; &nbsp;else
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// we set the id, now, we try to set the name if available in the sida
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (_SIDA != NULL)
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_Name = _SIDA-&gt;getString (id);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;TypeHasAName = true;
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+
+ &nbsp; &nbsp; &nbsp; &nbsp;_TypeSet = true;
+}
+
+/// Sets the message type as a string and put it in the buffer if we are in writing mode
+void CMessage::setType (const std::string &amp;name)
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;// check if we already do a setType ()
+ &nbsp; &nbsp; &nbsp; &nbsp;nlassert (!_TypeSet);
+ &nbsp; &nbsp; &nbsp; &nbsp;// don't accept empty string
+ &nbsp; &nbsp; &nbsp; &nbsp;nlassert (!name.empty ());
+
+ &nbsp; &nbsp; &nbsp; &nbsp;_Name = name;
+ &nbsp; &nbsp; &nbsp; &nbsp;TypeHasAnId = false;
+ &nbsp; &nbsp; &nbsp; &nbsp;TypeHasAName = true;
+
+ &nbsp; &nbsp; &nbsp; &nbsp;if (!isReading ())
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// check if they don't already serial some stuffs
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nlassert (length () == 0);
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// if we can send the id instead of the string, &quot;just do it&quot; (c)nike!
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//NLMISC::CStringIdArray::TStringId id = _SIDA-&gt;getId (name);
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// PATCH: always send in full text
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;NLMISC::CStringIdArray::TStringId id = -1;
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// Force binary mode for header
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;bool msgmode = _StringMode;
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_StringMode = false;
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// debug features, we number all packet to be sure that they are all sent and received
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// \todo remove this debug feature when ok
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// this value will be fill after in the callback function
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;uint32 zeroValue = 123;
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;serial (zeroValue);
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (id == -1)
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;uint8 format = FormatLong | (msgmode &lt;&lt; 1);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//nldebug( &quot;OUT format = %hu&quot;, (uint16)format );
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;serial (format);
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// End of binary header
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_StringMode = msgmode;
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;serial ((std::string&amp;)name);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;uint8 format = FormatShort | (msgmode &lt;&lt; 1);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//nldebug( &quot;OUT format = %hu&quot;, (uint16)format );
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;serial (format);
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// End of binary header
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_StringMode = msgmode;
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;serial (id);
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_Id = id;
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;TypeHasAnId = true;
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_HeaderSize = getPos ();
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+
+ &nbsp; &nbsp; &nbsp; &nbsp;_TypeSet = true;
+}
+
+/// Returns the size, in byte of the header that contains the type name of the message or the type number
+uint32 CMessage::getHeaderSize ()
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;nlassert (!isReading ());
+ &nbsp; &nbsp; &nbsp; &nbsp;nlassert (_HeaderSize != 0xFFFFFFFF);
+ &nbsp; &nbsp; &nbsp; &nbsp;return _HeaderSize;
+}
+
+// The message was filled with an CMemStream, Now, we'll get the message type on this buffer
+void CMessage::readType ()
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;nlassert (isReading ());
+
+ &nbsp; &nbsp; &nbsp; &nbsp;// debug features, we number all packet to be sure that they are all sent and received
+ &nbsp; &nbsp; &nbsp; &nbsp;// \todo remove this debug feature when ok
+
+ &nbsp; &nbsp; &nbsp; &nbsp;// we remove the message from the message
+ &nbsp; &nbsp; &nbsp; &nbsp;const uint HeaderSize = 4;
+ &nbsp; &nbsp; &nbsp; &nbsp;seek (HeaderSize, begin);
+// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;uint32 zeroValue;
+// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;serial (zeroValue);
+
+ &nbsp; &nbsp; &nbsp; &nbsp;// Force binary mode for header
+ &nbsp; &nbsp; &nbsp; &nbsp;_StringMode = false;
+
+ &nbsp; &nbsp; &nbsp; &nbsp;uint8 format;
+ &nbsp; &nbsp; &nbsp; &nbsp;serial (format);
+ &nbsp; &nbsp; &nbsp; &nbsp;//nldebug( &quot;IN format = %hu&quot;, (uint16)format );
+ &nbsp; &nbsp; &nbsp; &nbsp;bool LongFormat = (format &amp; 1);
+
+ &nbsp; &nbsp; &nbsp; &nbsp;// Set mode for the following of the buffer
+ &nbsp; &nbsp; &nbsp; &nbsp;_StringMode = (format &gt;&gt; 1) &amp; 1;
+ &nbsp; &nbsp; &nbsp; &nbsp;if (LongFormat)
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;std::string name;
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;serial (name);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;setType (name);
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+ &nbsp; &nbsp; &nbsp; &nbsp;else
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;NLMISC::CStringIdArray::TStringId id;
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;serial (id);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;setType (id);
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+}
+
+// Returns true if the message type was already set
+bool CMessage::typeIsSet () const
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;return _TypeSet;
+}
+
+// Clear the message. With this function, you can reuse a message to create another message
+void CMessage::clear ()
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;CMemStream::clear ();
+ &nbsp; &nbsp; &nbsp; &nbsp;_TypeSet = false;
+}
+
+/// Returns the type name in string if available. Be sure that the message have the name of the message type
+std::string CMessage::getName () const
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;nlassert (_TypeSet &amp;&amp; TypeHasAName);
+ &nbsp; &nbsp; &nbsp; &nbsp;return _Name;
+}
+
+/// Returns the type id of this message is available.
+NLMISC::CStringIdArray::TStringId CMessage::getId () const
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;nlassert (_TypeSet &amp;&amp; TypeHasAnId);
+ &nbsp; &nbsp; &nbsp; &nbsp;return _Id;
+}
+
+/** Returns a readable string to display it to the screen. It's only for debugging purpose!
+ * Don't use it for anything else than to debugging, the string format could change in the futur
+ */
+std::string CMessage::toString () const
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;nlassert (_TypeSet);
+ &nbsp; &nbsp; &nbsp; &nbsp;std::stringstream s;
+ &nbsp; &nbsp; &nbsp; &nbsp;if (TypeHasAName &amp;&amp; TypeHasAnId) s &lt;&lt; &quot;('&quot; &lt;&lt; _Name &lt;&lt; &quot;',&quot; &lt;&lt; _Id &lt;&lt; &quot;)&quot;;
+ &nbsp; &nbsp; &nbsp; &nbsp;else if (TypeHasAName) s &lt;&lt; &quot;('&quot; &lt;&lt; _Name &lt;&lt; &quot;',&quot; &lt;&lt; _SIDA-&gt;getId (_Name, true) &lt;&lt; &quot;)&quot;;
+ &nbsp; &nbsp; &nbsp; &nbsp;else if (TypeHasAnId) s &lt;&lt; &quot;('&quot; &lt;&lt; _SIDA-&gt;getString (_Id) &lt;&lt; &quot;',&quot; &lt;&lt; _Id &lt;&lt; &quot;')&quot;;
+ &nbsp; &nbsp; &nbsp; &nbsp;return s.str();
+}
+
+
+
+}
+</PRE> \ No newline at end of file