From 56b60ca408f525d16e7e7de9e0a7b03e4b8c8857 Mon Sep 17 00:00:00 2001 From: angelblue05 Date: Fri, 27 Mar 2015 04:45:28 -0500 Subject: [PATCH] Small modification to start websocket Step to eliminate the need to restart Kodi after setting the sources, etc. --- service.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/service.py b/service.py index 5096dbe2..d8000d7d 100644 --- a/service.py +++ b/service.py @@ -20,7 +20,8 @@ from WebSocketClient import WebSocketThread librarySync = LibrarySync() class Service(): - + + newWebSocketThread = None def __init__(self, *args ): self.KodiMonitor = KodiMonitor.Kodi_Monitor() @@ -34,15 +35,12 @@ class Service(): ConnectionManager().checkServer() - player = Player() - lastProgressUpdate = datetime.today() - - newWebSocketThread = WebSocketThread() - newWebSocketThread.start() - # check kodi library sources mayRun = utils.checkKodiSources() + player = Player() + lastProgressUpdate = datetime.today() + interval_FullSync = 120 interval_IncrementalSync = 30 @@ -50,6 +48,9 @@ class Service(): cur_seconds_incrsync = interval_IncrementalSync if mayRun: + + ws = WebSocketThread() + while not xbmc.abortRequested: xbmc.sleep(1000) @@ -79,6 +80,11 @@ class Service(): else: # background worker for database sync if DownloadUtils().authenticate(retreive=False) != "": + + # Correctly launch the websocket, if user manually launches the add-on + if (self.newWebSocketThread == None): + self.newWebSocketThread = "Started" + ws.start() #full sync if(cur_seconds_fullsync >= interval_FullSync): @@ -119,8 +125,8 @@ class Service(): utils.logMsg("MB3 Sync Service", "stopping Service",0) - if(newWebSocketThread != None): - newWebSocketThread.stopClient() + if (self.newWebSocketThread != None): + ws.stopClient() #start the service