diff --git a/.gitignore b/.gitignore index 96403d3..e5ddc82 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ __pycache__/* +test/__pycache__/* \ No newline at end of file diff --git a/ClientMsg.py b/ClientMsg.py index 6451d8e..a431436 100644 --- a/ClientMsg.py +++ b/ClientMsg.py @@ -8,10 +8,13 @@ class ClientMsg(IMessage): id = 0xA0 length = 2 + network_id = None + ## Create a Client message # # @param network_id The network id of the local participant. Use 0 if it is unknown def __init__(self, network_id): + if isinstance(network_id, int): self.network_id = network_id elif isinstance(network_id, bytes): diff --git a/ModelUrlMsg.py b/ModelUrlMsg.py index 863c1a2..bd670e2 100644 --- a/ModelUrlMsg.py +++ b/ModelUrlMsg.py @@ -3,6 +3,10 @@ from Messages import IMessage class ModelUrlMsg(IMessage): id = 0x90 length = 4 + + network_id = None + thing_id = None + url = None def __init__(self, data, thing = None): if isinstance(data, bytes): @@ -15,9 +19,6 @@ class ModelUrlMsg(IMessage): if thing is not None: self.thing_id = thing.id self.url = thing.model_url - else: - self.thing_id = None - self.url = None def Serialize(self, buffer_ref): if self.network_id is None or self.thing_id is None or self.url is None: diff --git a/NameMsg.py b/NameMsg.py index b799196..5acb8bd 100644 --- a/NameMsg.py +++ b/NameMsg.py @@ -4,6 +4,9 @@ class NameMsg(IMessage): id = 0x91 length = 4 + thing_id = None + name = None + def __init__(self, data, thing = None): if isinstance(data, bytes): self.network_id = data[1] @@ -15,9 +18,6 @@ class NameMsg(IMessage): if thing is not None: self.thing_id = thing.id self.name = thing.name - else: - self.thing_id = None - self.name = None def Serialize(self, buffer_ref): if self.network_id is None or self.thing_id is None or self.name is None: diff --git a/NetworkIdMsg.py b/NetworkIdMsg.py index d289042..280fae5 100644 --- a/NetworkIdMsg.py +++ b/NetworkIdMsg.py @@ -7,6 +7,8 @@ class NetworkIdMsg(IMessage): id = 0xA1 length = 2 + network_id = None + ## Create a network id message # # @param network_id The network id assigned to the remote participant. diff --git a/ThingMsg.py b/ThingMsg.py index 8c0ddcf..b97f597 100644 --- a/ThingMsg.py +++ b/ThingMsg.py @@ -4,6 +4,11 @@ class ThingMsg(IMessage): id = 0x80 length = 5 + network_id = None + thing_id = None + thing_type = None + parent_id = None + def __init__(self, data, thing=None): if isinstance(data, bytes): self.network_id = data[1] @@ -16,10 +21,6 @@ class ThingMsg(IMessage): self.thing_id = thing.id self.thing_type = thing.type self.parent_id = thing.parent_id - else: - self.thing_id = None - self.thing_type = None - self.parent_id = None def Serialize(self, buffer_ref): if self.network_id is None or self.thing_id is None: diff --git a/test/__pycache__/thing_test.cpython-312.pyc b/test/__pycache__/thing_test.cpython-312.pyc deleted file mode 100644 index 98a11fc..0000000 Binary files a/test/__pycache__/thing_test.cpython-312.pyc and /dev/null differ