webrtc handle.

This commit is contained in:
Miroslav Šedivý 2021-10-21 22:55:01 +02:00
parent 2068c0ee05
commit 60f459392a

View File

@ -12,18 +12,26 @@ func (manager *WebRTCManagerCtx) handle(data []byte, session types.Session) erro
// add session id to logger context // add session id to logger context
logger := manager.logger.With().Str("session_id", session.ID()).Logger() logger := manager.logger.With().Str("session_id", session.ID()).Logger()
buffer := bytes.NewBuffer(data) //
header := &payload.Header{} // parse header
hbytes := make([]byte, 3) //
buffer := bytes.NewBuffer(data)
hbytes := make([]byte, 3)
if _, err := buffer.Read(hbytes); err != nil { if _, err := buffer.Read(hbytes); err != nil {
return err return err
} }
header := &payload.Header{}
if err := binary.Read(bytes.NewBuffer(hbytes), binary.BigEndian, header); err != nil { if err := binary.Read(bytes.NewBuffer(hbytes), binary.BigEndian, header); err != nil {
return err return err
} }
//
// parse body
//
buffer = bytes.NewBuffer(data) buffer = bytes.NewBuffer(data)
switch header.Event { switch header.Event {