Skip to content

Commit

Permalink
Fix crash when session_id is null.
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudwebrtc committed Mar 16, 2020
1 parent 533528f commit 25f284d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pkg/signaler/signaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,11 @@ func (s *Signaler) HandleNewWebSocket(conn *websocket.WebSocketConn, request *ht
fallthrough
case "candidate":
{
if _, ok := data["to"]; !ok {
logger.Errorf("No to id found!")
return
}

To := data["to"].(string)
if peer, ok := s.peers[To]; !ok {
msg := map[string]interface{}{
Expand All @@ -213,6 +218,11 @@ func (s *Signaler) HandleNewWebSocket(conn *websocket.WebSocketConn, request *ht
break
case "bye":
{
if _, ok := data["session_id"]; !ok {
logger.Errorf("No session_id found!")
return
}

sessionID := data["session_id"].(string)
ids := strings.Split(sessionID, "-")
if len(ids) != 2 {
Expand Down

0 comments on commit 25f284d

Please sign in to comment.