diff --git a/src/network/network_manager.cpp b/src/network/network_manager.cpp index 04dd2128a..666708c73 100644 --- a/src/network/network_manager.cpp +++ b/src/network/network_manager.cpp @@ -108,7 +108,13 @@ void NetworkManager::setManualSocketsMode(bool manual) } // setManualSocketsMode //----------------------------------------------------------------------------- -void NetworkManager::notifyEvent(Event* event) +/** Is called from STKHost when an event (i.e. a package) is received. If the + * event indicates a new connection, the peer is added to the list of peers. + * It logs the package, and propagates the event to the ProtocollManager, + * which in turn will notify individual protocols. + * \param event Pointer to the event to propagate. + */ +void NetworkManager::propagateEvent(Event* event) { Log::verbose("NetworkManager", "EVENT received of type %d", (int)(event->getType())); @@ -135,8 +141,8 @@ void NetworkManager::notifyEvent(Event* event) } // notify for the event now. - ProtocolManager::getInstance()->notifyEvent(event); -} // notifyEvent + ProtocolManager::getInstance()->propagateEvent(event); +} // propagateEvent //----------------------------------------------------------------------------- diff --git a/src/network/network_manager.hpp b/src/network/network_manager.hpp index 9424a6af7..a2dcb1efb 100644 --- a/src/network/network_manager.hpp +++ b/src/network/network_manager.hpp @@ -75,7 +75,7 @@ class NetworkManager : public AbstractSingleton virtual void setManualSocketsMode(bool manual); // message/packets related functions - virtual void notifyEvent(Event* event); + virtual void propagateEvent(Event* event); virtual void sendPacket(const NetworkString& data, bool reliable = true) = 0; virtual void sendPacket(STKPeer* peer, diff --git a/src/network/protocol_manager.cpp b/src/network/protocol_manager.cpp index a5ad6c53f..d372ca948 100644 --- a/src/network/protocol_manager.cpp +++ b/src/network/protocol_manager.cpp @@ -95,7 +95,7 @@ void ProtocolManager::abort() } // abort // ---------------------------------------------------------------------------- -void ProtocolManager::notifyEvent(Event* event) +void ProtocolManager::propagateEvent(Event* event) { m_events_to_process.lock(); Event* event2 = new Event(*event); @@ -150,8 +150,8 @@ void ProtocolManager::notifyEvent(Event* event) Log::warn("ProtocolManager", "Received an event for %d that has no destination protocol.", searched_protocol); - m_events_to_process.lock(); -} // notifyEvent + m_events_to_process.unlock(); +} // propagateEvent // ---------------------------------------------------------------------------- void ProtocolManager::sendMessage(Protocol* sender, const NetworkString& message, diff --git a/src/network/protocol_manager.hpp b/src/network/protocol_manager.hpp index 59a8da116..418b17898 100644 --- a/src/network/protocol_manager.hpp +++ b/src/network/protocol_manager.hpp @@ -118,7 +118,7 @@ class ProtocolManager : public AbstractSingleton, * This function is called by the network manager each time there is an * incoming packet. */ - virtual void notifyEvent(Event* event); + virtual void propagateEvent(Event* event); /*! * \brief WILL BE COMMENTED LATER */ diff --git a/src/network/stk_host.cpp b/src/network/stk_host.cpp index 049a77559..d1377b2f2 100644 --- a/src/network/stk_host.cpp +++ b/src/network/stk_host.cpp @@ -182,7 +182,7 @@ void* STKHost::mainLoop(void* self) if (stk_event->getType() == EVENT_TYPE_MESSAGE) logPacket(stk_event->data(), true); if (event.type != ENET_EVENT_TYPE_NONE) - NetworkManager::getInstance()->notifyEvent(stk_event); + NetworkManager::getInstance()->propagateEvent(stk_event); delete stk_event; } // while enet_host_service } // while !mustStopListening