Skip to content

Commit

Permalink
call_job_state wsEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
cpoile committed Mar 13, 2024
1 parent 5477f59 commit b3dce1d
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions client/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ const (
)

const (
wsEventJoin = wsEvPrefix + "join"
wsEventLeave = wsEvPrefix + "leave"
wsEventReconnect = wsEvPrefix + "reconnect"
wsEventSignal = wsEvPrefix + "signal"
wsEventICE = wsEvPrefix + "ice"
wsEventSDP = wsEvPrefix + "sdp"
wsEventError = wsEvPrefix + "error"
wsEventUserLeft = wsEvPrefix + "user_left"
wsEventCallEnd = wsEvPrefix + "call_end"
wsEventCallRecordingState = wsEvPrefix + "call_recording_state"
wsEventJobStop = wsEvPrefix + "job_stop"
wsEventJoin = wsEvPrefix + "join"
wsEventLeave = wsEvPrefix + "leave"
wsEventReconnect = wsEvPrefix + "reconnect"
wsEventSignal = wsEvPrefix + "signal"
wsEventICE = wsEvPrefix + "ice"
wsEventSDP = wsEvPrefix + "sdp"
wsEventError = wsEvPrefix + "error"
wsEventUserLeft = wsEvPrefix + "user_left"
wsEventCallEnd = wsEvPrefix + "call_end"
wsEventCallJobState = wsEvPrefix + "call_job_state"
wsEventJobStop = wsEvPrefix + "job_stop"
)

var (
Expand Down Expand Up @@ -183,11 +183,18 @@ func (c *Client) handleWSMsg(msg ws.Message) error {
log.Printf("received call end event, closing client")
return errCallEnded
}
case wsEventCallRecordingState:
case wsEventCallJobState:
jobType, ok := ev.GetData()["type"].(string)
if !ok {
return fmt.Errorf("invalid type for job state event")
}
data, ok := ev.GetData()["jobState"].(map[string]any)
if !ok {
return fmt.Errorf("invalid recording state")
}
if jobType != "job_state_recording" {
return nil
}
var recState CallJobState
recState.FromMap(data)
c.emit(WSCallRecordingState, recState)
Expand Down

0 comments on commit b3dce1d

Please sign in to comment.