- Timestamp:
- Aug 4, 2011, 12:09:03 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/ai2/src/modules/notifications/NotificationDispatcher.cc
r8706 r8821 50 50 CreateUnloadableFactory(NotificationDispatcher); 51 51 52 registerMemberNetworkFunction(NotificationDispatcher, broadcastHelper); 52 53 registerMemberNetworkFunction(NotificationDispatcher, dispatch); 53 54 … … 61 62 62 63 this->sender_ = NotificationListener::NONE; 64 this->bBroadcast_ = false; 63 65 this->registerVariables(); 64 66 } … … 81 83 SUPER(NotificationDispatcher, XMLPort, xmlelement, mode); 82 84 83 XMLPortParam(NotificationDispatcher, "sender", getSender, setSender, xmlelement, mode); 84 85 XMLPortEventSink(NotificationDispatcher, BaseObject, "trigger", trigger, xmlelement, mode); //TODO: Change BaseObject to MultiTrigger as soon as MultiTrigger is the base of all triggers. 85 XMLPortParam(NotificationDispatcher, "sender", setSender, getSender, xmlelement, mode); 86 XMLPortParam(NotificationDispatcher, "meh", setBroadcasting, isBroadcasting, xmlelement, mode); 87 88 XMLPortEventSink(NotificationDispatcher, BaseObject, "trigger", trigger, xmlelement, mode); 86 89 } 87 90 … … 100 103 { 101 104 registerVariable(this->sender_, VariableDirection::ToClient); 105 } 106 107 /** 108 @brief 109 Broadcasts a specific Notification. 110 */ 111 void NotificationDispatcher::broadcast(void) 112 { 113 COUT(0) << "meh" << endl; 114 // TODO: Needed? 115 const std::string message = this->createNotificationMessage(); 116 NotificationListener::sendNotification(message, this->getSender(), notificationMessageType::info, notificationSendMode::local); 117 118 // Broadcast 119 if(!GameMode::isStandalone()) 120 { 121 callMemberNetworkFunction(NotificationDispatcher, broadcastHelper, this->getObjectID(), NETWORK_PEER_ID_BROADCAST); 122 } 123 } 124 125 /** 126 @brief 127 Helper function for broadcast. 128 */ 129 void NotificationDispatcher::broadcastHelper(void) 130 { 131 this->dispatch(Host::getPlayerID()); 102 132 } 103 133 … … 110 140 void NotificationDispatcher::dispatch(unsigned int clientId) 111 141 { 112 if(GameMode::isStandalone() || Host::getPlayerID() == clientId || this->getSyncMode() == 0x0) 142 // We don't call sendNotification() directly on the server, because if might be necessary that createNotificationMessage() is executed on the client as the message may be client-specific. 143 if(GameMode::isStandalone() || Host::getPlayerID() == clientId || this->getSyncMode() == ObjectDirection::None) 113 144 { 114 145 const std::string message = this->createNotificationMessage(); … … 139 170 COUT(4) << "NotificationDispatcher (&" << this << ") triggered." << std::endl; 140 171 172 // If the NotificationDispatcher is set to broadcast. 173 if(this->isBroadcasting()) 174 { 175 this->broadcast(); 176 return true; 177 } 178 141 179 PlayerTrigger* pTrigger = orxonox_cast<PlayerTrigger*>(trigger); 142 180 PlayerInfo* player = NULL;
Note: See TracChangeset
for help on using the changeset viewer.