00001 #ifndef IONFLUX_TOOLS_TCPMESSAGESERVER 00002 #define IONFLUX_TOOLS_TCPMESSAGESERVER 00003 /* ========================================================================== 00004 * Ionflux Tools 00005 * Copyright (c) 2004 Joern P. Meier 00006 * mail@ionflux.org 00007 * -------------------------------------------------------------------------- 00008 * TCPMessageServer.hpp Message based TCP server. 00009 * ========================================================================== 00010 * 00011 * This file is part of Ionflux Tools. 00012 * 00013 * Ionflux Tools is free software; you can redistribute it and/or modify it 00014 * under the terms of the GNU General Public License as published by the Free 00015 * Software Foundation; either version 2 of the License, or (at your option) 00016 * any later version. 00017 * 00018 * Ionflux Tools is distributed in the hope that it will be useful, but 00019 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 00020 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00021 * for more details. 00022 * 00023 * You should have received a copy of the GNU General Public License 00024 * along with Ionflux Tools; if not, write to the Free Software Foundation, 00025 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00026 * 00027 * ========================================================================== */ 00028 00029 #include <string> 00030 #include <iostream> 00031 #include <vector> 00032 #include "ionflux/TCPServer.hpp" 00033 #include "ionflux/MessageHandler.hpp" 00034 00035 namespace Ionflux 00036 { 00037 00038 namespace Tools 00039 { 00040 00048 class TCPMessageServer 00049 : public TCPServer, public MessageHandler 00050 { 00051 protected: 00060 virtual void onConnect(TCPRemotePeer &client); 00061 00074 virtual void onReceive(TCPRemotePeer &client); 00075 00076 public: 00081 TCPMessageServer(); 00082 00087 virtual ~TCPMessageServer(); 00088 00099 virtual void onMessage(TCPRemotePeer &peer); 00100 00109 virtual void onInvalidMessage(TCPRemotePeer &peer); 00110 00117 virtual void broadcast(const std::string &bytes); 00118 }; 00119 00120 } 00121 00122 } 00123 00127 #endif