

def message(connid, obj, alreadyjson=False):
    if (type(obj) is bytes):
        msgdat = obj
    else:
        if alreadyjson:
            msgstr = obj
        else:
            msgstr = json.dumps(obj)
        msgdat = msgstr.encode()
    head = struct.pack('<2I', len(msgdat), connid)
    return (head + msgdat)

dataset/ETHPy150Open erkyrath/tworld/lib/twcommon/wcproto.py message/original