Redo param init, handle reading createStream and placeholder for response

This commit is contained in:
Muaz Ahmad 2023-08-15 15:54:04 +05:00
parent 5efc3d0970
commit 56b6c2ff69
2 changed files with 31 additions and 3 deletions

View file

@ -18,7 +18,9 @@ func NewChunkWrapper(conn net.Conn) (chnk_wrp_ptr *ChunkWrapper) {
chnk_wrp_ptr = new(ChunkWrapper) chnk_wrp_ptr = new(ChunkWrapper)
chnk_wrp_ptr.conn = conn chnk_wrp_ptr.conn = conn
chnk_wrp_ptr.params = &ProtocolParams{1024, 512, 0, 0, ""} chnk_wrp_ptr.params = new(ProtocolParams)
chnk_wrp_ptr.params.chunk_size = 128
chnk_wrp_ptr.params.peer_chunk_size = 128
chnk_wrp_ptr.open_chnkstrms = make(map[uint32]*ChunkStream) chnk_wrp_ptr.open_chnkstrms = make(map[uint32]*ChunkStream)
chnk_wrp_ptr.open_msgs = make(map[uint32]*Message) chnk_wrp_ptr.open_msgs = make(map[uint32]*Message)
buffers := ChunkBuffers{ buffers := ChunkBuffers{
@ -138,3 +140,23 @@ func (chnk_wrp_ptr *ChunkWrapper) WriteConnectResponse() (error) {
} }
return nil return nil
} }
func (chnk_wrp_ptr *ChunkWrapper) ReadCreateStream() (error) {
create_stream_msg, err := chnk_wrp_ptr.ReadChunk()
if err != nil || create_stream_msg.msg_type != 20 {
return err
}
amf_obj, err := amf.DecodeAMF(&(create_stream_msg.data))
if err != nil {
return err
}
err = amf_obj.ProcessCreateStream(&(chnk_wrp_ptr.params.trans_id))
if err != nil {
return err
}
return nil
}
func (chnk_wrp_ptr *ChunkWrapper) WriteCreateStreamResponse() (error) {
return nil
}

View file

@ -31,7 +31,13 @@ func CreateStream(chnk_wrp_ptr *ChunkWrapper) (bool) {
if _, err := chnk_wrp_ptr.ReadChunk(); err != nil { if _, err := chnk_wrp_ptr.ReadChunk(); err != nil {
return false return false
} }
full_msg_ptr, _ := chnk_wrp_ptr.ReadChunk() if err := chnk_wrp_ptr.ReadCreateStream(); err != nil {
fmt.Println(full_msg_ptr) return false
}
fmt.Println("test read")
if err := chnk_wrp_ptr.WriteCreateStreamResponse(); err != nil {
return false
}
fmt.Println("test")
return true return true
} }