require handshake
This commit is contained in:
parent
30f8244abf
commit
628731cba4
@ -60,10 +60,14 @@ class SpectrumForwarder(object):
|
|||||||
|
|
||||||
class WebSocketMessageHandler(object):
|
class WebSocketMessageHandler(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
self.handshake = None
|
||||||
self.forwarder = None
|
self.forwarder = None
|
||||||
|
|
||||||
def handleTextMessage(self, conn, message):
|
def handleTextMessage(self, conn, message):
|
||||||
if (message[:16] == "SERVER DE CLIENT"):
|
if (message[:16] == "SERVER DE CLIENT"):
|
||||||
|
# maybe put some more info in there? nothing to store yet.
|
||||||
|
self.handshake = "completed"
|
||||||
|
|
||||||
config = {}
|
config = {}
|
||||||
pm = PropertyManager.getSharedInstance()
|
pm = PropertyManager.getSharedInstance()
|
||||||
|
|
||||||
@ -91,19 +95,24 @@ class WebSocketMessageHandler(object):
|
|||||||
|
|
||||||
self.dsp = DspManager(self.forwarder)
|
self.dsp = DspManager(self.forwarder)
|
||||||
|
|
||||||
else:
|
return
|
||||||
try:
|
|
||||||
message = json.loads(message)
|
|
||||||
if message["type"] == "dspcontrol":
|
|
||||||
if "params" in message:
|
|
||||||
params = message["params"]
|
|
||||||
for key, value in params.items():
|
|
||||||
self.dsp.setProperty(key, value)
|
|
||||||
|
|
||||||
if "action" in message and message["action"] == "start":
|
if not self.handshake:
|
||||||
self.dsp.start()
|
print("not answering client request since handshake is not complete")
|
||||||
except json.JSONDecodeError:
|
return
|
||||||
print("message is not json: {0}".format(message))
|
|
||||||
|
try:
|
||||||
|
message = json.loads(message)
|
||||||
|
if message["type"] == "dspcontrol":
|
||||||
|
if "params" in message:
|
||||||
|
params = message["params"]
|
||||||
|
for key, value in params.items():
|
||||||
|
self.dsp.setProperty(key, value)
|
||||||
|
|
||||||
|
if "action" in message and message["action"] == "start":
|
||||||
|
self.dsp.start()
|
||||||
|
except json.JSONDecodeError:
|
||||||
|
print("message is not json: {0}".format(message))
|
||||||
|
|
||||||
def handleBinaryMessage(self, conn, data):
|
def handleBinaryMessage(self, conn, data):
|
||||||
print("unsupported binary message, discarding")
|
print("unsupported binary message, discarding")
|
||||||
|
Loading…
Reference in New Issue
Block a user