- Timestamp:
- Jan 17, 2016, 10:29:21 PM (8 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/interfaces/NotificationListener.cc
r10624 r11071 74 74 The type of the notification, can be either 'info' or 'important'. 75 75 */ 76 /*static*/ void NotificationListener::sendNetworkHelper(const std::string& message, const std::string& sender, notificationSendMode::Value sendMode, unsigned int clientId, bool isCommand, notificationMessageType::Value messageType)76 /*static*/ void NotificationListener::sendNetworkHelper(const std::string& message, const std::string& sender, NotificationSendMode sendMode, unsigned int clientId, bool isCommand, NotificationMessageType messageType) 77 77 { 78 78 // If we're in standalone mode or we're already no the right client we create and send the notification/command. 79 if(GameMode::isStandalone() || sendMode == notificationSendMode::local || (sendMode == notificationSendMode::network && Host::getPlayerID() == clientId))79 if(GameMode::isStandalone() || sendMode == NotificationSendMode::local || (sendMode == NotificationSendMode::network && Host::getPlayerID() == clientId)) 80 80 { 81 81 sendHelper(message, sender, isCommand, messageType); 82 82 } 83 83 // If we're on the server (and the server is not the intended recipient of the notification/command) we send it over the network. 84 else if(GameMode::isServer() && sendMode == notificationSendMode::network && Host::getPlayerID() != clientId)84 else if(GameMode::isServer() && sendMode == NotificationSendMode::network && Host::getPlayerID() != clientId) 85 85 { 86 callStaticNetworkFunction(&NotificationListener::sendHelper, clientId, message, sender, isCommand, (unsigned int)messageType);86 callStaticNetworkFunction(&NotificationListener::sendHelper, clientId, message, sender, isCommand, messageType); 87 87 } 88 else if(GameMode::isServer() && sendMode == notificationSendMode::broadcast)88 else if(GameMode::isServer() && sendMode == NotificationSendMode::broadcast) 89 89 { 90 90 // TODO: Works as intended? 91 callStaticNetworkFunction(&NotificationListener::sendHelper, NETWORK_PEER_ID_BROADCAST, message, sender, isCommand, (unsigned int)messageType);91 callStaticNetworkFunction(&NotificationListener::sendHelper, NETWORK_PEER_ID_BROADCAST, message, sender, isCommand, messageType); 92 92 } 93 93 } … … 105 105 The type of the notification. 106 106 */ 107 /*static*/ void NotificationListener::sendHelper(const std::string& message, const std::string& sender, bool isCommand, unsigned int messageType)107 /*static*/ void NotificationListener::sendHelper(const std::string& message, const std::string& sender, bool isCommand, NotificationMessageType type) 108 108 { 109 109 // Iterate through all NotificationListeners and notify them by calling the method they overloaded. 110 for( ObjectList<NotificationListener>::iterator it = ObjectList<NotificationListener>::begin(); it != ObjectList<NotificationListener>::end(); ++it)110 for(NotificationListener* listener : ObjectList<NotificationListener>()) 111 111 { 112 112 // If the notification is a message. 113 113 if(!isCommand) 114 it->registerNotification(message, sender, notificationMessageType::Value(messageType));114 listener->registerNotification(message, sender, type); 115 115 116 116 // If the notification is a command. 117 117 if(isCommand) 118 118 { 119 notificationCommand::Valuecommand = str2Command(message);120 if(command != notificationCommand::none)121 it->executeCommand(command, sender);119 NotificationCommand command = str2Command(message); 120 if(command != NotificationCommand::none) 121 listener->executeCommand(command, sender); 122 122 } 123 123 } … … 130 130 The string to be converted. 131 131 @return 132 Returns the corresponding enum, notificationCommand::none if the command doesn't exist.132 Returns the corresponding enum, NotificationCommand::none if the command doesn't exist. 133 133 */ 134 /*static*/ notificationCommand::ValueNotificationListener::str2Command(const std::string& string)134 /*static*/ NotificationCommand NotificationListener::str2Command(const std::string& string) 135 135 { 136 notificationCommand::Value command = notificationCommand::none;136 NotificationCommand command = NotificationCommand::none; 137 137 138 138 if(string == NotificationListener::COMMAND_CLEAR) 139 command = notificationCommand::clear;139 command = NotificationCommand::clear; 140 140 141 141 return command; … … 150 150 Returns the corresponding string. 151 151 */ 152 /*static*/ const std::string& NotificationListener::command2Str( notificationCommand::Valuecommand)152 /*static*/ const std::string& NotificationListener::command2Str(NotificationCommand command) 153 153 { 154 154 switch(command) 155 155 { 156 case notificationCommand::clear:156 case NotificationCommand::clear: 157 157 return NotificationListener::COMMAND_CLEAR; 158 158 default:
Note: See TracChangeset
for help on using the changeset viewer.