This commit is contained in:
SpootDev 2016-03-31 14:48:52 -05:00
parent 9da11785d6
commit 372c61ef92

View file

@ -51,9 +51,7 @@ class WebSocket_Client(threading.Thread):
def sendProgressUpdate(self, data): def sendProgressUpdate(self, data):
log = self.logMsg self.logMsg("sendProgressUpdate", 2)
log("sendProgressUpdate", 2)
try: try:
messageData = { messageData = {
@ -62,14 +60,13 @@ class WebSocket_Client(threading.Thread):
} }
messageString = json.dumps(messageData) messageString = json.dumps(messageData)
self.client.send(messageString) self.client.send(messageString)
log("Message data: %s" % messageString, 2) self.logMsg("Message data: %s" % messageString, 2)
except Exception as e: except Exception as e:
log("Exception: %s" % e, 1) self.logMsg("Exception: %s" % e, 1)
def on_message(self, ws, message): def on_message(self, ws, message):
log = self.logMsg
window = utils.window window = utils.window
lang = utils.language lang = utils.language
@ -79,7 +76,7 @@ class WebSocket_Client(threading.Thread):
if messageType not in ('SessionEnded'): if messageType not in ('SessionEnded'):
# Mute certain events # Mute certain events
log("Message: %s" % message, 1) self.logMsg("Message: %s" % message, 1)
if messageType == "Play": if messageType == "Play":
# A remote control play command has been sent from the server. # A remote control play command has been sent from the server.
@ -129,10 +126,10 @@ class WebSocket_Client(threading.Thread):
seekto = data['SeekPositionTicks'] seekto = data['SeekPositionTicks']
seektime = seekto / 10000000.0 seektime = seekto / 10000000.0
action(seektime) action(seektime)
log("Seek to %s." % seektime, 1) self.logMsg("Seek to %s." % seektime, 1)
else: else:
action() action()
log("Command: %s completed." % command, 1) self.logMsg("Command: %s completed." % command, 1)
window('emby_command', value="true") window('emby_command', value="true")
@ -279,7 +276,6 @@ class WebSocket_Client(threading.Thread):
def run(self): def run(self):
log = self.logMsg
window = utils.window window = utils.window
monitor = self.monitor monitor = self.monitor
@ -298,7 +294,7 @@ class WebSocket_Client(threading.Thread):
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, deviceId)
log("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,
on_message=self.on_message, on_message=self.on_message,
@ -306,7 +302,7 @@ class WebSocket_Client(threading.Thread):
on_close=self.on_close) on_close=self.on_close)
self.client.on_open = self.on_open self.client.on_open = self.on_open
log("----===## Starting WebSocketClient ##===----", 0) self.logMsg("----===## Starting WebSocketClient ##===----", 0)
while not monitor.abortRequested(): while not monitor.abortRequested():
@ -318,7 +314,7 @@ class WebSocket_Client(threading.Thread):
# Abort was requested, exit # Abort was requested, exit
break break
log("##===---- WebSocketClient Stopped ----===##", 0) self.logMsg("##===---- WebSocketClient Stopped ----===##", 0)
def stopClient(self): def stopClient(self):