Try writing chunks, start with window ack size msg

This commit is contained in:
Muaz Ahmad 2023-08-13 14:30:39 +05:00
parent dbc55a2880
commit d90127def6
2 changed files with 30 additions and 1 deletions

View file

@ -4,6 +4,7 @@ import (
"net"
"encoding/binary"
"stream_server/rtmp/amf"
"fmt"
)
type ChunkWrapper struct {
@ -48,6 +49,20 @@ func (chnk_wrp_ptr *ChunkWrapper) ReadChunk() (*Message, error) {
return full_msg_ptr, nil
}
func (chnk_wrp_ptr *ChunkWrapper) WriteChunk(csid uint32, msg_strmid uint32, msg_ptr *Message) (error) {
err := WriteChunk(
chnk_wrp_ptr.conn,
csid,
msg_strmid,
msg_ptr,
chnk_wrp_ptr.params.chunk_size,
)
if err != nil {
return err
}
return nil
}
func (chnk_wrp_ptr *ChunkWrapper) ReadPeerChunkSize() (error) {
set_chunk_size_msg, err := chnk_wrp_ptr.ReadChunk()
if err != nil || set_chunk_size_msg.msg_type != 1 || set_chunk_size_msg.msg_len != 4 {
@ -71,5 +86,16 @@ func (chnk_wrp_ptr *ChunkWrapper) ReadConnectCommand() (error) {
return err
}
return err
}
func (chnk_wrp_ptr *ChunkWrapper) WriteWindowAckSize() (error) {
msg_ptr := new(Message)
msg_ptr.msg_type = 5
msg_ptr.data = make([]byte, 4)
msg_ptr.msg_len = 4
binary.BigEndian.PutUint32(msg_ptr.data, 5000000)
if err := chnk_wrp_ptr.WriteChunk(2, 0, msg_ptr); err != nil {
return err
}
return nil
}

View file

@ -11,6 +11,9 @@ func NegotiateConnect(chnk_wrp_ptr *ChunkWrapper) (bool) {
if err := chnk_wrp_ptr.ReadConnectCommand(); err != nil {
return false
}
if err := chnk_wrp_ptr.WriteWindowAckSize(); err != nil {
return false
}
fmt.Println(chnk_wrp_ptr.params)
return false
}