added chunk type 2 parse

This commit is contained in:
Muaz Ahmad 2023-08-10 13:09:26 +05:00
parent bb98894fc3
commit 37e28d88d3

View file

@ -9,6 +9,8 @@ import (
type chnk_stream struct {
timestamp uint32
last_msg_strm_id uint32
last_msg_len uint32
last_msg_type uint8
timedelta uint32
}
@ -127,11 +129,13 @@ func read_message_header_0(conn net.Conn, chnk_stream_ptr *chnk_stream, msg_ptr
return err
}
msg_ptr.data = make([]byte, msg_ptr.msg_len)
chnk_stream_ptr.last_msg_len = msg_ptr.msg_len
msg_ptr.msg_type, err = read_msg_typeid(conn, chunk_bufs_ptr)
if err != nil {
return err
}
chnk_stream_ptr.last_msg_type = msg_ptr.msg_type
chnk_stream_ptr.last_msg_strm_id, err = read_msg_streamid(conn, chunk_bufs_ptr)
if err != nil {
@ -162,11 +166,13 @@ func read_message_header_1(conn net.Conn, chnk_stream_ptr *chnk_stream, msg_ptr
return err
}
msg_ptr.data = make([]byte, msg_ptr.msg_len)
chnk_stream_ptr.last_msg_len = msg_ptr.msg_len
msg_ptr.msg_type, err = read_msg_typeid(conn, chunk_bufs_ptr)
if err != nil {
return err
}
chnk_stream_ptr.last_msg_type = msg_ptr.msg_type
if extended_time {
chnk_stream_ptr.timedelta, err = read_time_extd(conn, chunk_bufs_ptr)
@ -180,6 +186,34 @@ func read_message_header_1(conn net.Conn, chnk_stream_ptr *chnk_stream, msg_ptr
return nil
}
func read_message_header_2(conn net.Conn, chnk_stream_ptr *chnk_stream, msg_ptr *message, chunk_bufs_ptr *chunk_bufs) (error) {
var extended_time bool
var err error
chnk_stream_ptr.timedelta, extended_time, err = read_time(conn, chunk_bufs_ptr)
if err != nil {
return err
}
msg_ptr.msg_len = chnk_stream_ptr.last_msg_len
msg_ptr.data = make([]byte, msg_ptr.msg_len)
msg_ptr.msg_type = chnk_stream_ptr.last_msg_type
if extended_time {
chnk_stream_ptr.timedelta, err = read_time_extd(conn, chunk_bufs_ptr)
if err != nil {
return err
}
}
chnk_stream_ptr.timestamp += chnk_stream_ptr.timedelta
msg_ptr.timestamp = chnk_stream_ptr.timestamp
return nil
}
func read_chunk_data(conn net.Conn, msg_ptr *message, chnk_size uint32) (error) {
bytes_left := msg_ptr.msg_len - msg_ptr.curr_bytes_read
var buffer_end uint32
@ -224,6 +258,13 @@ func ReadChunk(conn net.Conn, open_chnkstrms map[uint32]*chnk_stream, open_msgs
if err := read_message_header_1(conn, chnkstream_ptr, msg_ptr, chunk_bufs_ptr); err != nil {
return nil, err
}
case 2:
chnkstream_ptr = open_chnkstrms[csid]
msg_ptr = new(message)
if err := read_message_header_2(conn, chnkstream_ptr, msg_ptr, chunk_bufs_ptr); err != nil {
return nil, err
}
}