commit
8e0704e706
2 changed files with 5 additions and 8 deletions
|
@ -119,17 +119,16 @@ class Message(object):
|
|||
"""
|
||||
Set the Token of the message.
|
||||
|
||||
:type value: String
|
||||
:type value: Bytes
|
||||
:param value: the Token
|
||||
:raise AttributeError: if value is longer than 256
|
||||
"""
|
||||
if value is None:
|
||||
self._token = value
|
||||
return
|
||||
if isinstance(value, int):
|
||||
value = bytes([value])
|
||||
if not isinstance(value, bytes):
|
||||
value = bytes(value, "utf-8")
|
||||
value = bytes(value)
|
||||
|
||||
if len(value) > 256:
|
||||
raise AttributeError
|
||||
self._token = value
|
||||
|
|
|
@ -157,10 +157,8 @@ class Serializer(object):
|
|||
values = [tmp, message.code, message.mid]
|
||||
|
||||
if message.token is not None and tkl > 0:
|
||||
|
||||
for b in message.token:
|
||||
fmt += "B"
|
||||
values.append(b)
|
||||
fmt += "%ss" % tkl
|
||||
values.append(message.token)
|
||||
|
||||
options = Serializer.as_sorted_list(message.options) # already sorted
|
||||
lastoptionnumber = 0
|
||||
|
|
Loading…
Reference in a new issue