-
-
Save Tey/4311c5334a536684799c487533002506 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git "a/C:\\Games\\World_of_Tanks\\res_mods\\mods\\packages\\xvm_battle\\python\\xmqp.py.bak" "b/C:\\Games\\World_of_Tanks\\res_mods\\mods\\packages\\xvm_battle\\python\\xmqp.py" | |
index a6e605a..2c22a08 100644 | |
--- "a/C:\\Games\\World_of_Tanks\\res_mods\\mods\\packages\\xvm_battle\\python\\xmqp.py.bak" | |
+++ "b/C:\\Games\\World_of_Tanks\\res_mods\\mods\\packages\\xvm_battle\\python\\xmqp.py" | |
@@ -26,11 +26,13 @@ import xvm_main.python.utils as utils | |
from xvm_main.python.consts import * | |
from consts import * | |
+from xvm_main.python.xvm import Xvm | |
XMQP_DEVELOPMENT = os.environ.get('XMQP_DEVELOPMENT') == '1' | |
_xmqp = None | |
_xmqp_thread = None | |
+_start_delayed = False | |
def is_active(): | |
global _xmqp_thread, _xmqp | |
@@ -40,7 +42,30 @@ def start(): | |
BigWorld.player().arena.onNewVehicleListReceived -= start | |
BigWorld.callback(0, _start) | |
+@registerEvent(Xvm, 'initializeXvmServices') # FIXME: use some kind of event for that instead? | |
+def onInitializeXvmServices(*args, **kwargs): | |
+ debug('[XMQP] onInitializeXvmServices()') | |
+ global _start_delayed | |
+ | |
+ if not config.networkServicesSettings.servicesActive: | |
+ # Token not downloaded yet (if game restarted after crash) or XVM disabled | |
+ return | |
+ | |
+ if _start_delayed and config.networkServicesSettings.xmqp: | |
+ _start_delayed = False | |
+ BigWorld.callback(0, _start) | |
+ | |
def _start(): | |
+ debug('[XMQP] _start()') | |
+ global _start_delayed | |
+ | |
+ if not config.networkServicesSettings.servicesActive: | |
+ # Token not downloaded yet (if game restarted after crash) or XVM disabled | |
+ _start_delayed = True # Try again if we finally receive a token | |
+ return | |
+ | |
+ _start_delayed = False | |
+ | |
if config.networkServicesSettings.xmqp or (isReplay() and XMQP_DEVELOPMENT): | |
token = config.token.token | |
if token: | |
@@ -66,13 +91,14 @@ def _start(): | |
debug('[XMQP] Thread started') | |
def stop(): | |
- global _xmqp_thread, _xmqp | |
+ global _xmqp_thread, _xmqp, _start_delayed | |
if _xmqp_thread: | |
_xmqp.stop() | |
_xmqp_thread.join() | |
_xmqp_thread = None | |
debug('[XMQP] Thread stopped') | |
_xmqp = None | |
+ _start_delayed = False | |
def call(message): | |
global _xmqp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment