You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
507 B
22 lines
507 B
"""
|
|
@author Georg Hopp
|
|
|
|
"""
|
|
|
|
import struct
|
|
|
|
class Composer(object):
|
|
def compose(self, message):
|
|
"""
|
|
for now I only encode messages of len less than 126 and
|
|
final...this is just for testing.
|
|
"""
|
|
msglen = len(message)
|
|
if msglen > 125:
|
|
raise Exception('messages bigger than 125 bytes not supported')
|
|
|
|
frame = struct.pack('BB%ds'%msglen, int('10000010', 2), msglen, message)
|
|
|
|
return frame
|
|
|
|
# vim: set ft=python et ts=8 sw=4 sts=4:
|