00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00031
00032 #ifndef _QAVATARMANAGER_H
00033 #define _QAVATARMANAGER_H
00034
00035 #include <QAvatar.h>
00036 class QAvatarFactory;
00037 class QAvatarListener;
00038
00039 #include <QUANTA/QUANTAmisc_hashDict.hxx>
00040 class QUANTAnet_tcpReflectorClient_c;
00041 class QUANTAnet_udp_c;
00042
00043 #ifdef USE_STL_NAMESPACE
00044 #include <list>
00045 using std::list;
00046 #else
00047 #include <list.h>
00048 #endif
00049
00056 class QAvatarManager
00057 {
00058 protected:
00059
00060 static const char AUX_MSG;
00061 static const char BYE_MSG;
00062 static const char HELLO_MSG;
00063 static const char TRACKER_MSG;
00064
00065 public:
00066
00068 QAvatarManager(QAvatarFactory*);
00069
00071 virtual ~QAvatarManager();
00072
00074 void checkForTimeouts();
00075
00077 virtual bool connect(const char*,
00078 const unsigned short&, const unsigned short&);
00079
00081 QAvatar* getSelfAvatar();
00082
00084 void attach(QAvatarListener*);
00085
00087 void detach(QAvatarListener*);
00088
00090 virtual void process();
00091
00093 virtual bool sendAux();
00094
00096 virtual bool sendBye();
00097
00099 virtual bool sendHello();
00100
00102 virtual bool sendTracker();
00103
00104 void setDataSizes(const size_t&, const size_t&, const size_t&);
00105
00107 void setTrackerUpdateDelay(const double&);
00108
00109 protected:
00110
00112 virtual void handleHailingData(char*, const size_t&);
00113
00115 virtual void handleTrackerData(char*, const size_t&);
00116
00118
00119
00121 void notifyArrive(QAvatar*);
00122
00124 void notifyAux(QAvatar*);
00125
00127 void notifyBye(QAvatar*);
00128
00130 void notifyHello(QAvatar*);
00131
00133 void notifyTracker(QAvatar*);
00134
00136
00137 protected:
00138
00140 QUANTAmisc_hashDict<QAvatar*, long>* m_avatarDB;
00141
00143 QAvatar* m_selfAvatar;
00144
00146 QAvatarFactory* m_avatarFactory;
00147
00149 QUANTAnet_tcpReflectorClient_c* m_hailingTCP;
00150
00152 QUANTAnet_udp_c* m_trackerUDP;
00153
00155 bool m_noNetworking;
00156
00157 char* m_hailingBuffer;
00158 size_t m_hailingBufSize;
00159 char* m_trackerBuffer;
00160 size_t m_trackerBufSize;
00161
00162 double m_lastTimeTrackerSent;
00163 double m_trackerDelay;
00164
00165 char* m_tempBuffer;
00166
00167 typedef list<QAvatarListener*> ListenerList;
00168 ListenerList m_listeners;
00169 };
00170
00171 #endif