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
logger := manager.logger.With().Str("session_id", session.ID()).Logger()
buffer := bytes.NewBuffer(data)
header := &payload.Header{}
hbytes := make([]byte, 3)
//
// parse header
//
buffer := bytes.NewBuffer(data)
hbytes := make([]byte, 3)
if _, err := buffer.Read(hbytes); err != nil {
return err
}
header := &payload.Header{}
if err := binary.Read(bytes.NewBuffer(hbytes), binary.BigEndian, header); err != nil {
return err
}
//
// parse body
//
buffer = bytes.NewBuffer(data)
switch header.Event {