code reduce
This commit is contained in:
parent
372c61ef92
commit
0d2efbed1f
1 changed files with 3 additions and 7 deletions
|
@ -277,23 +277,19 @@ class WebSocket_Client(threading.Thread):
|
||||||
def run(self):
|
def run(self):
|
||||||
|
|
||||||
window = utils.window
|
window = utils.window
|
||||||
monitor = self.monitor
|
|
||||||
|
|
||||||
loglevel = int(window('emby_logLevel'))
|
loglevel = int(window('emby_logLevel'))
|
||||||
# websocket.enableTrace(True)
|
# websocket.enableTrace(True)
|
||||||
|
|
||||||
userId = window('emby_currUser')
|
userId = window('emby_currUser')
|
||||||
server = window('emby_server%s' % userId)
|
server = window('emby_server%s' % userId)
|
||||||
token = window('emby_accessToken%s' % userId)
|
token = window('emby_accessToken%s' % userId)
|
||||||
deviceId = self.deviceId
|
|
||||||
|
|
||||||
# Get the appropriate prefix for the websocket
|
# Get the appropriate prefix for the websocket
|
||||||
if "https" in server:
|
if "https" in server:
|
||||||
server = server.replace('https', "wss")
|
server = server.replace('https', "wss")
|
||||||
else:
|
else:
|
||||||
server = server.replace('http', "ws")
|
server = server.replace('http', "ws")
|
||||||
|
|
||||||
websocket_url = "%s?api_key=%s&deviceId=%s" % (server, token, deviceId)
|
websocket_url = "%s?api_key=%s&deviceId=%s" % (server, token, self.deviceId)
|
||||||
self.logMsg("websocket url: %s" % websocket_url, 1)
|
self.logMsg("websocket url: %s" % websocket_url, 1)
|
||||||
|
|
||||||
self.client = websocket.WebSocketApp(websocket_url,
|
self.client = websocket.WebSocketApp(websocket_url,
|
||||||
|
@ -304,13 +300,13 @@ class WebSocket_Client(threading.Thread):
|
||||||
self.client.on_open = self.on_open
|
self.client.on_open = self.on_open
|
||||||
self.logMsg("----===## Starting WebSocketClient ##===----", 0)
|
self.logMsg("----===## Starting WebSocketClient ##===----", 0)
|
||||||
|
|
||||||
while not monitor.abortRequested():
|
while not self.monitor.abortRequested():
|
||||||
|
|
||||||
self.client.run_forever(ping_interval=10)
|
self.client.run_forever(ping_interval=10)
|
||||||
if self.stopWebsocket:
|
if self.stopWebsocket:
|
||||||
break
|
break
|
||||||
|
|
||||||
if monitor.waitForAbort(5):
|
if self.monitor.waitForAbort(5):
|
||||||
# Abort was requested, exit
|
# Abort was requested, exit
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue