00001 /***************************** License ********************************** 00002 00003 Copyright (C) 2008 by Communicative Machines 00004 http://www.cmlabs.com All rights reserved. 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Lesser General Public 00008 License as published by the Free Software Foundation; either 00009 version 2.1 of the License, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Lesser General Public License for more details. 00015 00016 You should have received a copy of the GNU Lesser General Public 00017 License along with this library; if not, write to the Free Software 00018 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 00020 ************************************************************************/ 00021 00022 00023 // TCPReceiver.h: interface for the TCPReceiver class. 00024 // 00025 ////////////////////////////////////////////////////////////////////// 00026 00027 #if !defined(_NETPROTOCOL_H_) 00028 #define _NETPROTOCOL_H_ 00029 00030 #if _MSC_VER > 1000 00031 #pragma once 00032 #endif // _MSC_VER > 1000 00033 00034 #include "Object.h" 00035 #include "JString.h" 00036 #include "Message.h" 00037 // #include <socket.h> 00038 00039 namespace cmlabs { 00040 00041 class JSocket; 00042 class NetProtocol; 00043 00044 class NetProtocol : public Object 00045 { 00046 public: 00047 NetProtocol(JString pname); 00048 virtual ~NetProtocol(); 00049 00050 JString name; 00051 int netTimeout; 00052 00053 NetProtocol* prev; 00054 NetProtocol* next; 00055 00056 bool isLocalCallback; 00057 bool isRemoteCallback; 00058 00059 virtual bool equals(NetProtocol* protocol); 00060 virtual Object* clone() const = 0; 00061 virtual bool checkBufferForCompatibility(char* buffer, int length) = 0; 00062 virtual bool initializeConversation(JSocket* socket) = 0; 00063 virtual bool initializeAsReceiver(JSocket* socket, JString from); 00064 00065 virtual bool sendObject(JSocket* socket, Object* obj, bool isReply); 00066 virtual bool sendObject(JSocket* socket, Message* msg, bool isReply) = 0; 00067 virtual Message* receiveObject(JSocket* socket, int timeout) = 0; 00068 00069 double getSendProgress(); 00070 int currentUnsentBufferSize; 00071 int currentSentBufferSize; 00072 00073 double getReceiveProgress(); 00074 int currentUnreceivedBufferSize; 00075 int currentReceivedBufferSize; 00076 00077 00078 // virtual void tcpInput(JString str, NetworkConnection* con); 00079 // void tcpInput(JString str); 00080 // virtual bool OnAccept(const InetHostAddress &ia, tpport_t portIn); 00081 }; 00082 00083 } // namespace cmlabs 00084 00085 #include "Network.h" 00086 00087 #endif // !defined(_NETPROTOCOL_H_)