OverSim
PubSubMMOG.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2006 Institut fuer Telematik, Universitaet Karlsruhe (TH)
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 //
18 
24 #ifndef __PUBSUBMMOG_H_
25 #define __PUBSUBMMOG_H_
26 
27 #include <omnetpp.h>
28 #include <NodeHandle.h>
29 #include <BaseOverlay.h>
30 #include "PubSubSubspace.h"
31 #include "PubSubMessage_m.h"
32 
33 class PubSubMMOG : public BaseOverlay
34 {
35  public:
36  // OMNeT++
37  virtual ~PubSubMMOG();
38  virtual void initializeOverlay(int stage);
39  virtual void finishOverlay();
40  virtual void handleUDPMessage(BaseOverlayMessage* msg);
41  virtual void handleTimerEvent(cMessage* msg);
42  virtual void handleAppMessage(cMessage* msg);
43  virtual void receiveChangeNotification(int category, const cPolymorphic *details);
44  virtual bool handleRpcCall(BaseCallMessage* msg);
45  virtual void handleRpcResponse(BaseResponseMessage *msg,
46  cPolymorphic* context,
47  int rpcId, simtime_t rtt);
48  virtual void handleRpcTimeout(BaseCallMessage *msg,
49  const TransportAddress & dest,
50  cPolymorphic* context,
51  int rpcId, const OverlayKey &destKey);
52 
53  protected:
54 
55  void setBootstrapedIcon();
56  void handleMove( GameAPIPositionMessage* posMsg );
57  void handleMoveMessage( PubSubMoveMessage* moveMsg );
59  void handleJoinResponse( PubSubJoinResponse* joinResp );
64  void handleHelpResponse( PubSubHelpResponse* helpResp );
65  void handleBackupCall( PubSubBackupCall* backupCall );
66  void handleBackupResponse( PubSubBackupResponse* backupResp );
67  void handleIntermediateCall( PubSubIntermediateCall* intermediateCall );
69  void handleAdoptChildCall( PubSubAdoptChildCall* adoptCall );
71  void handlePingCall( PubSubPingCall* hearbeatCall );
72  void handlePingResponse( PubSubPingResponse* pingResp );
73 
74  void takeOverNewSubspace( PubSubSubspaceId subspaceId );
75  void takeOverSubspace( PubSubSubspaceResponsible& subspaceId, bool isNew );
77  void sendPingToChildren();
78  void handleParentTimeout( PubSubTimer* timer );
79  void handleBackupCallTimeout( PubSubBackupCall* backupCall, const TransportAddress& oldNode );
80  void handlePingCallTimeout( PubSubPingCall* pingCall, const TransportAddress& oldNode );
81  void handleSubscriptionCallTimeout( PubSubSubscriptionCall* subscriptionCall, const TransportAddress& oldNode );
89 
90  void unsubscribeChild( const NodeHandle& node, PubSubSubspaceResponsible& subspace );
92  BaseOverlayMessage* toIntermediates,
93  BaseOverlayMessage* toBackup,
94  BaseOverlayMessage* toPlayers );
95 
96  void publishEvents();
97  void startTimer( PubSubTimer* timer );
98 
99  std::list<PubSubSubspace> subscribedSubspaces;
100  std::map<PubSubSubspaceId, PubSubSubspaceResponsible> responsibleSubspaces;
101  std::map<PubSubSubspaceId, PubSubSubspaceResponsible> backupSubspaces;
102  std::map<PubSubSubspaceId, PubSubSubspaceIntermediate> intermediateSubspaces;
103 
105  int AOIWidth;
106 
110 
112 
119  cMessage* joinTimer;
121 
122  // statistics
134 };
135 
136 #endif