• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

ReadyEvent.h

Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 #include "NativeFeatureIncludes.h"
00009 #if _RAKNET_SUPPORT_ReadyEvent==1
00010 
00011 #ifndef __READY_EVENT_H
00012 #define __READY_EVENT_H
00013 
00014 class RakPeerInterface;
00015 #include "PluginInterface2.h"
00016 #include "DS_OrderedList.h"
00017 
00022 
00025 enum ReadyEventSystemStatus
00026 {
00030         RES_NOT_WAITING,
00032         RES_WAITING,
00034         RES_READY,
00037         RES_ALL_READY,
00038 
00040         RES_UNKNOWN_EVENT,
00041 };
00042 
00052 class ReadyEvent : public PluginInterface2
00053 {
00054 public:
00055         // Constructor
00056         ReadyEvent();
00057 
00058         // Destructor
00059         virtual ~ReadyEvent();
00060 
00061         // --------------------------------------------------------------------------------------------
00062         // User functions
00063         // --------------------------------------------------------------------------------------------
00073         bool SetEvent(int eventId, bool isReady);
00074 
00080         bool ForceCompletion(int eventId);
00081 
00086         bool DeleteEvent(int eventId);
00087 
00090         bool IsEventSet(int eventId);
00091 
00097         bool IsEventCompletionProcessing(int eventId) const;
00098 
00104         bool IsEventCompleted(int eventId) const;
00105 
00110         bool HasEvent(int eventId);
00111 
00114         unsigned GetEventListSize(void) const;
00115 
00119         int GetEventAtIndex(unsigned index) const;
00120 
00128         bool AddToWaitList(int eventId, SystemAddress address);
00129         
00134         bool RemoveFromWaitList(int eventId, SystemAddress address);
00135 
00140         bool IsInWaitList(int eventId, SystemAddress address);
00141         
00146         unsigned GetRemoteWaitListSize(int eventId) const;
00147 
00152         SystemAddress GetFromWaitListAtIndex(int eventId, unsigned index) const;
00153                 
00158         ReadyEventSystemStatus GetReadyStatus(int eventId, SystemAddress address);
00159 
00162         void SetSendChannel(unsigned char newChannel);
00163 
00164         // ---------------------------- ALL INTERNAL AFTER HERE ----------------------------
00167         struct RemoteSystem
00168         {
00169                 MessageID lastSentStatus, lastReceivedStatus;
00170                 SystemAddress systemAddress;
00171         };
00172         static int RemoteSystemCompBySystemAddress( const SystemAddress &key, const RemoteSystem &data );
00175         struct ReadyEventNode
00176         {
00177                 int eventId; // Sorted on this
00178                 MessageID eventStatus;
00179                 DataStructures::OrderedList<SystemAddress,RemoteSystem,ReadyEvent::RemoteSystemCompBySystemAddress> systemList;
00180         };
00181         static int ReadyEventNodeComp( const int &key, ReadyEvent::ReadyEventNode * const &data );
00182 
00183 
00184 protected:
00185         // --------------------------------------------------------------------------------------------
00186         // Packet handling functions
00187         // --------------------------------------------------------------------------------------------
00188         virtual PluginReceiveResult OnReceive(Packet *packet);
00189         virtual void OnClosedConnection(SystemAddress systemAddress, RakNetGUID rakNetGUID, PI2_LostConnectionReason lostConnectionReason );
00190         virtual void OnRakPeerShutdown(void);
00191         
00192         void Clear(void);
00193         /*
00194         bool AnyWaitersCompleted(unsigned eventIndex) const;
00195         bool AllWaitersCompleted(unsigned eventIndex) const;
00196         bool AllWaitersReady(unsigned eventIndex) const;
00197         void SendAllReady(unsigned eventId, SystemAddress address);
00198         void BroadcastAllReady(unsigned eventIndex);
00199         void SendReadyStateQuery(unsigned eventId, SystemAddress address);
00200         void BroadcastReadyUpdate(unsigned eventIndex);
00201         bool AddToWaitListInternal(unsigned eventIndex, SystemAddress address);
00202         bool IsLocked(unsigned eventIndex) const;
00203         bool IsAllReadyByIndex(unsigned eventIndex) const;
00204         */
00205 
00206         void SendReadyStateQuery(unsigned eventId, SystemAddress address);
00207         void SendReadyUpdate(unsigned eventIndex, unsigned systemIndex, bool forceIfNotDefault);
00208         void BroadcastReadyUpdate(unsigned eventIndex, bool forceIfNotDefault);
00209         void RemoveFromAllLists(SystemAddress address);
00210         void OnReadyEventQuery(Packet *packet);
00211         void PushCompletionPacket(unsigned eventId);
00212         bool AddToWaitListInternal(unsigned eventIndex, SystemAddress address);
00213         void OnReadyEventForceAllSet(Packet *packet);
00214         void OnReadyEventPacketUpdate(Packet *packet);
00215         void UpdateReadyStatus(unsigned eventIndex);
00216         bool IsEventCompletedByIndex(unsigned eventIndex) const;
00217         unsigned CreateNewEvent(int eventId, bool isReady);
00218         bool SetEventByIndex(int eventIndex, bool isReady);
00219 
00220         DataStructures::OrderedList<int, ReadyEventNode*, ReadyEvent::ReadyEventNodeComp> readyEventNodeList;
00221         unsigned char channel;
00222 };
00223 
00224 #endif
00225 
00226 #endif // _RAKNET_SUPPORT_*

Generated on Thu Sep 30 2010 01:27:27 for RakNet by  doxygen 1.7.1