import { decodeText, encodeText } from "./byte_util";
import { Bytes } from "./rtmt";

const headerLenght = 4

export type Message = {
    channel: string,
    message: Object,
}
 
//
// channel is string, message is byte array
//
export function encode(message: Message) {
    return JSON.stringify({
        channel : message.channel,
        message : message.message
    });
}

// 
// return { channel :  string, message :  byte array} 
//
export function decode(bytes: string): Message {
    return JSON.parse(bytes);
}
