Finish stream creation response
This commit is contained in:
parent
9f0cf39b3b
commit
4f4a896b84
3 changed files with 26 additions and 4 deletions
|
@ -72,3 +72,13 @@ func EncodeConnectResponse() ([]byte, error) {
|
||||||
|
|
||||||
return Encode(amf_root_obj)
|
return Encode(amf_root_obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func EncodeCreateStreamResponse(trans_id float64) ([]byte, error) {
|
||||||
|
amf_root_obj := make(AMFObj)
|
||||||
|
amf_root_obj[0] = "_result"
|
||||||
|
amf_root_obj[1] = trans_id
|
||||||
|
amf_root_obj[2] = nil
|
||||||
|
amf_root_obj[3] = 1.0
|
||||||
|
|
||||||
|
return Encode(amf_root_obj)
|
||||||
|
}
|
||||||
|
|
|
@ -19,8 +19,8 @@ func NewChunkWrapper(conn net.Conn) (chnk_wrp_ptr *ChunkWrapper) {
|
||||||
|
|
||||||
chnk_wrp_ptr.conn = conn
|
chnk_wrp_ptr.conn = conn
|
||||||
chnk_wrp_ptr.params = new(ProtocolParams)
|
chnk_wrp_ptr.params = new(ProtocolParams)
|
||||||
chnk_wrp_ptr.params.chunk_size = 128
|
chnk_wrp_ptr.params.chunk_size = 256
|
||||||
chnk_wrp_ptr.params.peer_chunk_size = 128
|
chnk_wrp_ptr.params.peer_chunk_size = 4096
|
||||||
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{
|
||||||
|
@ -158,5 +158,17 @@ func (chnk_wrp_ptr *ChunkWrapper) ReadCreateStream() (error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (chnk_wrp_ptr *ChunkWrapper) WriteCreateStreamResponse() (error) {
|
func (chnk_wrp_ptr *ChunkWrapper) WriteCreateStreamResponse() (error) {
|
||||||
|
msg_ptr := new(Message)
|
||||||
|
msg_ptr.msg_type = 20
|
||||||
|
msg_data, err := amf.EncodeCreateStreamResponse(chnk_wrp_ptr.params.trans_id)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
msg_ptr.msg_len = uint32(len(msg_data))
|
||||||
|
msg_ptr.data = msg_data
|
||||||
|
|
||||||
|
if err := chnk_wrp_ptr.WriteChunk(3, 0, msg_ptr); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,10 +34,10 @@ func CreateStream(chnk_wrp_ptr *ChunkWrapper) (bool) {
|
||||||
if err := chnk_wrp_ptr.ReadCreateStream(); err != nil {
|
if err := chnk_wrp_ptr.ReadCreateStream(); err != nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
fmt.Println("test read")
|
|
||||||
if err := chnk_wrp_ptr.WriteCreateStreamResponse(); err != nil {
|
if err := chnk_wrp_ptr.WriteCreateStreamResponse(); err != nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
fmt.Println("test")
|
p, _ := chnk_wrp_ptr.ReadChunk()
|
||||||
|
fmt.Println(p)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue