- Timestamp:
- Sep 2, 2010, 10:06:51 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/notifications/src/modules/notifications/Notification.cc
r7193 r7324 35 35 36 36 #include "core/CoreIncludes.h" 37 #include "network/NetworkFunction.h" 37 38 #include "NotificationManager.h" 38 39 … … 42 43 CreateUnloadableFactory(Notification); 43 44 45 registerMemberNetworkFunction(Notification, send); 46 44 47 /** 45 48 @brief 46 49 Default constructor. Initializes the object. 47 50 */ 48 Notification::Notification(BaseObject* creator) : BaseObject(creator) 51 Notification::Notification(BaseObject* creator) : BaseObject(creator), Synchronisable(creator) 49 52 { 50 53 RegisterObject(Notification); 51 54 this->initialize(); 55 this->registerVariables(); 52 56 } 53 57 … … 58 62 The message of the Notification. 59 63 */ 60 Notification::Notification(BaseObject* creator, const std::string & message) : BaseObject(creator) 64 Notification::Notification(BaseObject* creator, const std::string & message) : BaseObject(creator), Synchronisable(creator) 61 65 { 62 66 RegisterObject(Notification); 63 67 this->initialize(); 64 68 this->message_ = message; 69 this->registerVariables(); 65 70 } 66 71 … … 85 90 } 86 91 87 /** 88 @brief 89 Sends the Notification to the Notificationmanager, with sender NetificationManager::NONE. 90 @return 91 Returns true if successful. 92 */ 93 bool Notification::send(void) 92 void Notification::registerVariables(void) 94 93 { 95 return this->send(NotificationManager::NONE); 94 registerVariable(this->message_); 95 registerVariable(this->sender_); 96 registerVariable(this->sent_); 96 97 } 97 98 … … 104 105 Returns true if successful. 105 106 */ 106 bool Notification::send( const std::string & sender)107 bool Notification::send(unsigned int clientId, const std::string & sender = NotificationManager::NONE) 107 108 { 108 if(this->isSent()) //TODO: Needed? 109 return false; 110 111 this->sender_ = sender; 112 bool successful = NotificationManager::getInstance().registerNotification(this); 113 if(!successful) 114 return false; 115 this->sent_ = true; 109 if(GameMode::isMaster()) 110 { 111 if(this->isSent()) //TODO: Needed? 112 return false; 116 113 117 COUT(3) << "Notification \"" << this->getMessage() << "\" sent." << std::endl; 114 this->sender_ = sender; 115 bool successful = NotificationManager::getInstance().registerNotification(this); 116 if(!successful) 117 return false; 118 this->sent_ = true; 119 120 COUT(3) << "Notification \"" << this->getMessage() << "\" sent." << std::endl; 121 } 122 else 123 { 124 callMemberNetworkFunction(Notification, send, this->getObjectID(), clientId, clientId, sender); 125 } 118 126 119 127 return true;
Note: See TracChangeset
for help on using the changeset viewer.