Skip to content

Commit

Permalink
pure call events
Browse files Browse the repository at this point in the history
  • Loading branch information
sdfsdhgjkbmnmxc committed Mar 18, 2021
1 parent bd8d759 commit 9a34e84
Showing 1 changed file with 2 additions and 20 deletions.
22 changes: 2 additions & 20 deletions ws.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (

"github.com/google/uuid"
"github.com/gorilla/websocket"
"github.com/pion/webrtc/v2"
"github.com/pkg/errors"
"github.com/tada-team/tdproto"
"github.com/tada-team/timerpool"
Expand Down Expand Up @@ -238,37 +237,20 @@ func (w WsSession) inboxLoop() {
}
}

func (w *WsSession) SendCallOffer(jid tdproto.JID, sdp string) (res webrtc.SessionDescription, err error) {
func (w *WsSession) SendCallOffer(jid tdproto.JID, sdp string) {
callOffer := new(tdproto.ClientCallOffer)
callOffer.Name = callOffer.GetName()
callOffer.Params.Jid = jid
callOffer.Params.Trickle = false
callOffer.Params.Sdp = sdp
w.Send(callOffer)

callAnswer := new(tdproto.ServerCallAnswer)
if err := w.WaitFor(callAnswer); err != nil {
return res, err
}

return webrtc.SessionDescription{
Type: webrtc.SDPTypeAnswer,
SDP: callAnswer.Params.JSEP.SDP,
}, nil
}

func (w *WsSession) SendCallLeave(jid tdproto.JID) error {
func (w *WsSession) SendCallLeave(jid tdproto.JID) {
callLeave := new(tdproto.ClientCallLeave)
callLeave.Name = callLeave.GetName()
callLeave.Params.Jid = jid
callLeave.Params.Reason = ""
w.Send(callLeave)

serverLeaveAnswer := new(tdproto.ServerCallLeave)
if err := w.WaitFor(serverLeaveAnswer); err != nil {
return err
}

return nil
}

0 comments on commit 9a34e84

Please sign in to comment.