30 lines
897 B
Python
30 lines
897 B
Python
from Messages.Messages import IMessage
|
|
|
|
## A network id message invites another participant to a site
|
|
#
|
|
## This can be sent in response to a ClientMsg
|
|
class NetworkIdMsg(IMessage):
|
|
id = 0xA1
|
|
length = 2
|
|
|
|
## Create a network id message
|
|
def __init__(self, arg1 = None):
|
|
if isinstance(arg1, bytes):
|
|
buffer = arg1
|
|
self.network_id = buffer[1]
|
|
else:
|
|
self.network_id = arg1
|
|
|
|
## Serialize the message into the given buffer
|
|
#
|
|
## @param buffer_ref A reference to the buffer to use. This should be a list with the buffer as its first and only element
|
|
## @returns the length of the message
|
|
def Serialize(self, buffer_ref):
|
|
buffer: bytearray = buffer_ref[0]
|
|
buffer[0:NetworkIdMsg.length] = [
|
|
NetworkIdMsg.id,
|
|
self.network_id
|
|
]
|
|
return NetworkIdMsg.length
|
|
|