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 <QUANTA/QUANTAmisc_hashDict.hxx>
00036 class QUANTAnet_tcpReflectorClient_c;
00037 class QUANTAnet_udp_c;
00038
00039 #include <QAvatar.h>
00040 class QAvatarFactory;
00041 class QAvatarListener;
00042
00043 #ifdef USE_STL_NAMESPACE
00044 #include <list>
00045 using std::list;
00046 #else
00047 #include <list.h>
00048 #endif
00049
00057 class QAvatarManager
00058 {
00059 protected:
00060
00061 static const char AUX_MSG;
00062 static const char BYE_MSG;
00063 static const char HELLO_MSG;
00064 static const char TRACKER_MSG;
00065
00066 public:
00067
00069 QAvatarManager(QAvatarFactory*);
00070
00072 virtual ~QAvatarManager();
00073
00075 void checkForTimeouts();
00076
00078 virtual bool connect(const char*,
00079 const unsigned short&, const unsigned short&);
00080
00082 QAvatar* getSelfAvatar();
00083
00085 void attach(QAvatarListener*);
00086
00088 void detach(QAvatarListener*);
00089
00091 virtual void process();
00092
00094 virtual bool sendAux();
00095
00097 virtual bool sendBye();
00098
00100 virtual bool sendHello();
00101
00103 virtual bool sendTracker();
00104
00105 void setDataSizes(const size_t&, const size_t&, const size_t&);
00106
00108 void setTrackerUpdateDelay(const double&);
00109
00110 protected:
00111
00113 virtual void handleHailingData(char*, const size_t&);
00114
00116 virtual void handleTrackerData(char*, const size_t&);
00117
00119
00120
00122 void notifyArrive(QAvatar*);
00123
00125 void notifyAux(QAvatar*);
00126
00128 void notifyBye(QAvatar*);
00129
00131 void notifyHello(QAvatar*);
00132
00134 void notifyTracker(QAvatar*);
00135
00137
00138 protected:
00139
00141 QUANTAmisc_hashDict<QAvatar*, long>* m_avatarDB;
00142
00144 QAvatar* m_selfAvatar;
00145
00147 QAvatarFactory* m_avatarFactory;
00148
00150 QUANTAnet_tcpReflectorClient_c* m_hailingTCP;
00151
00153 QUANTAnet_udp_c* m_trackerUDP;
00154
00156 bool m_noNetworking;
00157
00158 char* m_hailingBuffer;
00159 size_t m_hailingBufSize;
00160 char* m_trackerBuffer;
00161 size_t m_trackerBufSize;
00162
00163 double m_lastTimeTrackerSent;
00164 double m_trackerDelay;
00165
00166 char* m_tempBuffer;
00167
00168 typedef list<QAvatarListener*> ListenerList;
00169 ListenerList m_listeners;
00170 };
00171
00172 #endif