Fix message unpacking for commander
This commit is contained in:
@@ -60,7 +60,12 @@ class Commander:
|
|||||||
self.make_decision()
|
self.make_decision()
|
||||||
|
|
||||||
def on_message(self, client, userdata, message):
|
def on_message(self, client, userdata, message):
|
||||||
messageDict = umsgpack.unpackb()
|
try:
|
||||||
|
messageDict = umsgpack.unpackb(message.payload)
|
||||||
|
except:
|
||||||
|
print("Incorrect Message")
|
||||||
|
return
|
||||||
|
|
||||||
if "type" in messageDict.keys:
|
if "type" in messageDict.keys:
|
||||||
# Need to consider that a malicious message may have a type with incorrect subtypes.
|
# Need to consider that a malicious message may have a type with incorrect subtypes.
|
||||||
if messageDict["type"] == "connect":
|
if messageDict["type"] == "connect":
|
||||||
|
|||||||
Reference in New Issue
Block a user