proper variable initialization
This commit is contained in:
parent
67cac9bdbd
commit
a00c6822ce
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
||||
__pycache__/*
|
||||
test/__pycache__/*
|
@ -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):
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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.
|
||||
|
@ -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:
|
||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user