Small modification to start websocket

Step to eliminate the need to restart Kodi after setting the sources, etc.
This commit is contained in:
angelblue05 2015-03-27 04:45:28 -05:00
parent a69918f13f
commit 56b60ca408

View file

@ -21,6 +21,7 @@ librarySync = LibrarySync()
class Service(): class Service():
newWebSocketThread = None
def __init__(self, *args ): def __init__(self, *args ):
self.KodiMonitor = KodiMonitor.Kodi_Monitor() self.KodiMonitor = KodiMonitor.Kodi_Monitor()
@ -34,15 +35,12 @@ class Service():
ConnectionManager().checkServer() ConnectionManager().checkServer()
player = Player()
lastProgressUpdate = datetime.today()
newWebSocketThread = WebSocketThread()
newWebSocketThread.start()
# check kodi library sources # check kodi library sources
mayRun = utils.checkKodiSources() mayRun = utils.checkKodiSources()
player = Player()
lastProgressUpdate = datetime.today()
interval_FullSync = 120 interval_FullSync = 120
interval_IncrementalSync = 30 interval_IncrementalSync = 30
@ -50,6 +48,9 @@ class Service():
cur_seconds_incrsync = interval_IncrementalSync cur_seconds_incrsync = interval_IncrementalSync
if mayRun: if mayRun:
ws = WebSocketThread()
while not xbmc.abortRequested: while not xbmc.abortRequested:
xbmc.sleep(1000) xbmc.sleep(1000)
@ -80,6 +81,11 @@ class Service():
# background worker for database sync # background worker for database sync
if DownloadUtils().authenticate(retreive=False) != "": 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 #full sync
if(cur_seconds_fullsync >= interval_FullSync): if(cur_seconds_fullsync >= interval_FullSync):
xbmc.log("Doing_Db_Sync: syncDatabase (Started)") xbmc.log("Doing_Db_Sync: syncDatabase (Started)")
@ -119,8 +125,8 @@ class Service():
utils.logMsg("MB3 Sync Service", "stopping Service",0) utils.logMsg("MB3 Sync Service", "stopping Service",0)
if(newWebSocketThread != None): if (self.newWebSocketThread != None):
newWebSocketThread.stopClient() ws.stopClient()
#start the service #start the service