Force read peer chunk size message from client

This commit is contained in:
Muaz Ahmad 2023-08-10 20:58:01 +05:00
parent 5df64adcbd
commit c7ea01e3bd
2 changed files with 15 additions and 0 deletions

View file

@ -2,6 +2,7 @@ package rtmp
import ( import (
"net" "net"
"encoding/binary"
) )
type ChunkWrapper struct { type ChunkWrapper struct {
@ -45,3 +46,12 @@ func (chnk_wrp_ptr *ChunkWrapper) ReadChunk() (*Message, error) {
} }
return full_msg_ptr, nil return full_msg_ptr, 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 {
return err
}
chnk_wrp_ptr.params.peer_chunk_size = binary.BigEndian.Uint32(set_chunk_size_msg.data)
return nil
}

View file

@ -5,6 +5,11 @@ import (
) )
func NegotiateConnect(chnk_wrp_ptr *ChunkWrapper) (bool) { func NegotiateConnect(chnk_wrp_ptr *ChunkWrapper) (bool) {
fmt.Println(chnk_wrp_ptr.params.peer_chunk_size)
if err := chnk_wrp_ptr.ReadPeerChunkSize(); err != nil {
return false
}
fmt.Println(chnk_wrp_ptr.params.peer_chunk_size)
for { for {
full_msg_ptr, err := chnk_wrp_ptr.ReadChunk() full_msg_ptr, err := chnk_wrp_ptr.ReadChunk()
if err != nil { if err != nil {