diff --git a/direct/src/http/baseincomingset.h b/direct/src/http/baseincomingset.h index 525e8da037..d56acddd1c 100644 --- a/direct/src/http/baseincomingset.h +++ b/direct/src/http/baseincomingset.h @@ -4,10 +4,10 @@ #include #include "socket_base.h" -enum CloseState +enum CloseState { - ConnectionDoNotClose, - ConnectionDoClose + ConnectionDoNotClose, + ConnectionDoClose }; // RHH //////////////////////////////////////////////////////////////////// @@ -20,15 +20,15 @@ enum CloseState // // The general operation if get connection.. // do you have a message -// process message +// process message // go back to do you have a message or close connection // // //////////////////////////////////////////////////////////////////// template < class _INCLASS1,class _IN_LISTEN, class MESSAGE_READER_BUF, class MESSAGE_READER_UPPASS> class BaseIncomingSet : public std::list<_INCLASS1 *> { - typedef std::list<_INCLASS1 *> BaseClass; - typedef TYPENAME BaseClass::iterator iterator; + typedef std::list<_INCLASS1 *> BaseClass; + typedef TYPENAME BaseClass::iterator iterator; _IN_LISTEN _Listener; inline void AddFromListener(void); @@ -39,7 +39,7 @@ public: // typedef typename BaseIncomingSet<_INCLASS1, _IN_LISTEN, MESSAGE_READER_BUF, MESSAGE_READER_UPPASS>::LinkNode LinkNode; -// typedef SentDblLinkListNode_Gm SentDblLinkListNode_Gm; +// typedef SentDblLinkListNode_Gm SentDblLinkListNode_Gm; inline BaseIncomingSet(void); inline BaseIncomingSet(BaseIncomingSet &in); virtual ~BaseIncomingSet(); @@ -50,10 +50,6 @@ public: virtual CloseState ProcessNewConnection(SOCKET socket); inline void AddToFDSet(Socket_fdset &set); - - - - // inline LinkNode * GetRoot(void) { return &this->sentenal; }; BaseIncomingSet &operator=( BaseIncomingSet &inval); void Reset(); diff --git a/direct/src/http/baseincomingset.i b/direct/src/http/baseincomingset.i index 8d377b3792..32cdf8eaee 100644 --- a/direct/src/http/baseincomingset.i +++ b/direct/src/http/baseincomingset.i @@ -1,19 +1,19 @@ //////////////////////////////////////////////////////////////////// // Function name : BaseIncomingSet<_INCLASS1,_IN_LISTEN,MESSAGE_READER_BUF,MESSAGE_READER_UPPASS>::AddFromListener // Description : Read incoming connections off the listener -// -// Return type : inline void +// +// Return type : inline void // Argument : void //////////////////////////////////////////////////////////////////// -template +template inline void BaseIncomingSet<_INCLASS1,_IN_LISTEN,MESSAGE_READER_BUF,MESSAGE_READER_UPPASS>::AddFromListener(void) { Socket_Address Addr1; SOCKET newsck; - - + + while(_Listener.GetIncomingConnection(newsck,Addr1) == true) - { + { CloseState cl= ProcessNewConnection(newsck); if(cl == ConnectionDoNotClose) { @@ -22,52 +22,52 @@ inline void BaseIncomingSet<_INCLASS1,_IN_LISTEN,MESSAGE_READER_BUF,MESSAGE_READ } else DO_CLOSE(newsck); - } - + } + } //////////////////////////////////////////////////////////////////// // Function name : BaseIncomingSet<_INCLASS1,_IN_LISTEN,MESSAGE_READER_BUF,MESSAGE_READER_UPPASS>::PumpReader // Description : Tries to read a record off the incoming socket -// -// Return type : inline void +// +// Return type : inline void // Argument : Time_Clock currentTime //////////////////////////////////////////////////////////////////// -template +template inline int BaseIncomingSet<_INCLASS1,_IN_LISTEN,MESSAGE_READER_BUF,MESSAGE_READER_UPPASS>::PumpReader(Time_Clock ¤tTime) -{ +{ MESSAGE_READER_BUF message; - + iterator lpNext, lp; for (lpNext = lp = BaseClass::begin(); lp != BaseClass::end() ; lp = lpNext) { - lpNext++; - + lpNext++; + int ans = (*lp)->ReadIt(message, sizeof(message),currentTime); if(ans < 0) { delete *lp; - erase(lp); - } + this->erase(lp); + } if(ans > 0) { CloseState cs = (*lp)->ProcessMessage(message,currentTime); if( cs == ConnectionDoClose) { delete *lp; - erase(lp); + this->erase(lp); } } - } - return 0; + } + return 0; } //////////////////////////////////////////////////////////////////// // Function name : BaseIncomingSet<_INCLASS1,_IN_LISTEN,MESSAGE_READER_BUF,MESSAGE_READER_UPPASS>::AddAConection // Description : Adds a member to the base container -// -// Return type : inline void +// +// Return type : inline void // Argument : _INCLASS1 * newt //////////////////////////////////////////////////////////////////// -template +template inline void BaseIncomingSet<_INCLASS1,_IN_LISTEN,MESSAGE_READER_BUF,MESSAGE_READER_UPPASS>::AddAConection(_INCLASS1 * newt) { push_back(newt); @@ -75,17 +75,17 @@ inline void BaseIncomingSet<_INCLASS1,_IN_LISTEN,MESSAGE_READER_BUF,MESSAGE_READ //////////////////////////////////////////////////////////////////// // Function name : BaseIncomingSet<_INCLASS1,_IN_LISTEN,MESSAGE_READER_BUF,MESSAGE_READER_UPPASS>::BaseIncomingSet // Description : core constructor -// -// Return type : inline +// +// Return type : inline // Argument : void //////////////////////////////////////////////////////////////////// -template +template inline BaseIncomingSet<_INCLASS1,_IN_LISTEN,MESSAGE_READER_BUF,MESSAGE_READER_UPPASS>::BaseIncomingSet(void) { - + } -template +template BaseIncomingSet<_INCLASS1,_IN_LISTEN,MESSAGE_READER_BUF,MESSAGE_READER_UPPASS>::BaseIncomingSet(BaseIncomingSet &in) { @@ -93,10 +93,10 @@ BaseIncomingSet<_INCLASS1,_IN_LISTEN,MESSAGE_READER_BUF,MESSAGE_READER_UPPASS>:: //////////////////////////////////////////////////////////////////// // Function name : BaseIncomingSet<_INCLASS1,_IN_LISTEN,MESSAGE_READER_BUF,MESSAGE_READER_UPPASS>::~BaseIncomingSet // Description : The Destructot .. will delete all members.. ?? -// -// Return type : +// +// Return type : //////////////////////////////////////////////////////////////////// -template +template BaseIncomingSet<_INCLASS1,_IN_LISTEN,MESSAGE_READER_BUF,MESSAGE_READER_UPPASS>::~BaseIncomingSet() { for(iterator ii = BaseClass::begin(); ii != BaseClass::end(); ii++) @@ -105,76 +105,76 @@ BaseIncomingSet<_INCLASS1,_IN_LISTEN,MESSAGE_READER_BUF,MESSAGE_READER_UPPASS>:: //////////////////////////////////////////////////////////////////// // Function name : & BaseIncomingSet<_INCLASS1,_IN_LISTEN,MESSAGE_READER_BUF,MESSAGE_READER_UPPASS>::GetListener // Description : Retyurns a pointer to the listener in this class -// -// Return type : inline _IN_LISTEN +// +// Return type : inline _IN_LISTEN // Argument : void //////////////////////////////////////////////////////////////////// -template -inline _IN_LISTEN & BaseIncomingSet<_INCLASS1,_IN_LISTEN,MESSAGE_READER_BUF,MESSAGE_READER_UPPASS>::GetListener(void) -{ - return this->Listener; +template +inline _IN_LISTEN & BaseIncomingSet<_INCLASS1,_IN_LISTEN,MESSAGE_READER_BUF,MESSAGE_READER_UPPASS>::GetListener(void) +{ + return this->Listener; }; //////////////////////////////////////////////////////////////////// // Function name : BaseIncomingSet<_INCLASS1,_IN_LISTEN,MESSAGE_READER_BUF,MESSAGE_READER_UPPASS>::init // Description : the second part of the 2 phase power up.. Opends the listener -// -// Return type : inline bool +// +// Return type : inline bool // Argument : Socket_Address &WhereFrom //////////////////////////////////////////////////////////////////// -template +template inline bool BaseIncomingSet<_INCLASS1,_IN_LISTEN,MESSAGE_READER_BUF,MESSAGE_READER_UPPASS>::init(Socket_Address &WhereFrom) { if(_Listener.OpenForListen(WhereFrom,true) != true) - return false; + return false; _Listener.SetNonBlocking(); return true; } //////////////////////////////////////////////////////////////////// // Function name : BaseIncomingSet<_INCLASS1,_IN_LISTEN,MESSAGE_READER_BUF,MESSAGE_READER_UPPASS>::PumpAll // Description : THis is the polled interface to this class -// -// Return type : inline void +// +// Return type : inline void // Argument : Time_Clock ¤tTime //////////////////////////////////////////////////////////////////// -template +template inline void BaseIncomingSet<_INCLASS1,_IN_LISTEN,MESSAGE_READER_BUF,MESSAGE_READER_UPPASS>::PumpAll(Time_Clock ¤tTime) { PumpReader(currentTime); // I MOVED ORDER TO FINE TUNE THE READ OPERATIONS - AddFromListener(); + AddFromListener(); } //////////////////////////////////////////////////////////////////// // Function name : BaseIncomingSet<_INCLASS1,_IN_LISTEN,MESSAGE_READER_BUF,MESSAGE_READER_UPPASS>::ProcessNewConnection -// Description : this is the vertual function call when a new connection is created +// Description : this is the vertual function call when a new connection is created // manly here for loging if needed... -// -// Return type : CloseState +// +// Return type : CloseState // Argument : SOCKET socket //////////////////////////////////////////////////////////////////// -template +template CloseState BaseIncomingSet<_INCLASS1,_IN_LISTEN,MESSAGE_READER_BUF,MESSAGE_READER_UPPASS>::ProcessNewConnection(SOCKET socket) { return ConnectionDoNotClose; } //////////////////////////////////////////////////////////////////// // Function name : void BaseIncomingSet<_INCLASS1,_IN_LISTEN,MESSAGE_READER_BUF,MESSAGE_READER_UPPASS>::AddToFDSet -// Description : Add LIstener and Client to the FD set for polled reading -// -// Return type : inline +// Description : Add LIstener and Client to the FD set for polled reading +// +// Return type : inline // Argument : Socket_Selector &set //////////////////////////////////////////////////////////////////// -template +template inline void BaseIncomingSet<_INCLASS1,_IN_LISTEN,MESSAGE_READER_BUF,MESSAGE_READER_UPPASS>::AddToFDSet(Socket_fdset &set1) -{ +{ if(_Listener.Active()) set1.setForSocket(_Listener); iterator lp; - + for (lp = BaseClass::begin(); lp != BaseClass::end(); lp = lp++) set1.setForSocket((*lp)->val); } -template +template inline BaseIncomingSet<_INCLASS1,_IN_LISTEN,MESSAGE_READER_BUF,MESSAGE_READER_UPPASS> &BaseIncomingSet<_INCLASS1,_IN_LISTEN,MESSAGE_READER_BUF,MESSAGE_READER_UPPASS>::operator= (BaseIncomingSet &inval) { @@ -184,18 +184,18 @@ inline BaseIncomingSet<_INCLASS1,_IN_LISTEN,MESSAGE_READER_BUF,MESSAGE_READER_UP } -template +template inline void BaseIncomingSet<_INCLASS1,_IN_LISTEN,MESSAGE_READER_BUF,MESSAGE_READER_UPPASS>::Reset() { _Listener.Close(); iterator lpNext, lp; for (lpNext = lp = BaseClass::begin(); lp != BaseClass::end() ; lp = lpNext) { - lpNext++; + lpNext++; (*lp)->Reset(); delete *lp; - erase(lp); - } + this->erase(lp); + } }