feat(Core/Scripting): Pass IoContext to OnNetworkStart (#25501)

This commit is contained in:
Axel Cocat 2026-04-23 16:41:26 +02:00 committed by GitHub
parent c83fc175a3
commit 4fd0c385da
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 8 additions and 5 deletions

View file

@ -15,13 +15,14 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ServerScript.h"
#include "IoContext.h"
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
#include "ServerScript.h"
void ScriptMgr::OnNetworkStart()
void ScriptMgr::OnNetworkStart(Acore::Asio::IoContext& ioContext)
{
CALL_ENABLED_HOOKS(ServerScript, SERVERHOOK_ON_NETWORK_START, script->OnNetworkStart());
CALL_ENABLED_HOOKS(ServerScript, SERVERHOOK_ON_NETWORK_START, script->OnNetworkStart(ioContext));
}
void ScriptMgr::OnNetworkStop()

View file

@ -18,6 +18,7 @@
#ifndef SCRIPT_OBJECT_SERVER_SCRIPT_H_
#define SCRIPT_OBJECT_SERVER_SCRIPT_H_
#include "IoContext.h"
#include "ScriptObject.h"
#include <vector>
#include <memory> // NOTE: this import is NEEDED (even though some IDEs report it as unused)
@ -41,6 +42,7 @@ protected:
public:
// Called when reactive socket I/O is started (WorldSocketMgr).
virtual void OnNetworkStart() { }
virtual void OnNetworkStart(Acore::Asio::IoContext& /*ioContext*/) { OnNetworkStart(); }
// Called when reactive I/O is stopped.
virtual void OnNetworkStop() { }

View file

@ -154,7 +154,7 @@ public: /* SpellScriptLoader */
void CreateSpellScriptLoaders(uint32 spellId, std::vector<std::pair<SpellScriptLoader*, std::multimap<uint32, uint32>::iterator>>& scriptVector);
public: /* ServerScript */
void OnNetworkStart();
void OnNetworkStart(Acore::Asio::IoContext& ioContext);
void OnNetworkStop();
void OnSocketOpen(std::shared_ptr<WorldSocket> const& socket);
void OnSocketClose(std::shared_ptr<WorldSocket> const& socket);

View file

@ -70,7 +70,7 @@ bool WorldSocketMgr::StartWorldNetwork(Acore::Asio::IoContext& ioContext, std::s
_acceptor->AsyncAcceptWithCallback<&WorldSocketMgr::OnSocketAccept>();
sScriptMgr->OnNetworkStart();
sScriptMgr->OnNetworkStart(ioContext);
return true;
}