2 Copied from PLIB into SimGear
4 PLIB - A Suite of Portable Game Libraries
5 Copyright (C) 1998,2002 Steve Baker
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
17 You should have received a copy of the GNU Library General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 For further information visit http://plib.sourceforge.net
23 $Id: netChat.h 1568 2002-09-02 06:05:49Z sjbaker $
28 * netChat - network chat class
31 * This class adds support for 'chat' style protocols -
32 * where one side sends a 'command', and the other sends
33 * a response (examples would be the common internet
34 * protocols - smtp, nntp, ftp, etc..).
36 * The handle_buffer_read() method looks at the input
37 * stream for the current 'terminator' (usually '\r\n'
38 * for single-line responses, '\r\n.\r\n' for multi-line
39 * output), calling found_terminator() on its receipt.
42 * Say you build an nntp client using this class.
43 * At the start of the connection, you'll have
44 * terminator set to '\r\n', in order to process
45 * the single-line greeting. Just before issuing a
46 * 'LIST' command you'll set it to '\r\n.\r\n'.
47 * The output of the LIST command will be accumulated
48 * (using your own 'collect_incoming_data' method)
49 * up to the terminator, and then control will be
50 * returned to you - by calling your found_terminator()
53 * Sam Rushing <rushing@nightmare.com> - original version for Medusa
54 * Dave McClurg <dpm@efn.org> - modified for use in PLIB
66 #include <simgear/io/sg_netBuffer.hxx>
71 class NetChat : public NetBufferChannel
75 virtual void handleBufferRead (NetBuffer& buffer) ;
84 void setTerminator (const char* t);
85 const char* getTerminator (void);
88 * set byte count to collect - 'foundTerminator' will be called once
89 * this many bytes have been collected
91 void setByteCount(int bytes);
93 bool push (const char* s);
95 virtual void collectIncomingData (const char* s, int n) {}
96 virtual void foundTerminator (void) {}
99 } // of namespace simgear
101 #endif // SG_NET_CHAT_H