Skip to content

Commit

Permalink
drop GetIceServer
Browse files Browse the repository at this point in the history
  • Loading branch information
sdfsdhgjkbmnmxc committed Mar 15, 2021
1 parent 2f7f507 commit 396c1c6
Showing 1 changed file with 0 additions and 40 deletions.
40 changes: 0 additions & 40 deletions utils.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
package tdclient

import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"math/rand"
"net/http"
"time"

"github.com/pion/webrtc/v2"
"github.com/tada-team/tdproto"
Expand Down Expand Up @@ -64,42 +60,6 @@ func NewPeerConnection(login string, iceServer string) (peerConnection *webrtc.P
return peerConnection, offer, outputTrack, nil
}

func GetIceServer(host string) (string, error) {
req, err := http.NewRequest(http.MethodGet, host+"/features.json", nil)
if err != nil {
return "", fmt.Errorf("failed to create new http request: %v", err)
}

cli := http.Client{
Timeout: time.Second * 2,
}
res, getErr := cli.Do(req)
if getErr != nil {
return "", fmt.Errorf("failed to get features.json: %v", err)
}

if res.Body != nil {
defer res.Body.Close()
}

body, readErr := ioutil.ReadAll(res.Body)
if readErr != nil {
return "", fmt.Errorf("failed to read request body: %v", readErr)
}

features := tdproto.Features{}
jsonErr := json.Unmarshal(body, &features)
if jsonErr != nil {
return "", fmt.Errorf("failed to unmarshal features json: %v", jsonErr)
}

if len(features.ICEServers) > 0 {
return features.ICEServers[0].Urls, nil
}

return "", nil
}

func SendCallOffer(c *WsSession, userName string, callJid *tdproto.JID, sdp string) (res webrtc.SessionDescription, err error) {
callOffer := new(tdproto.ClientCallOffer)
callOffer.Name = callOffer.GetName()
Expand Down

0 comments on commit 396c1c6

Please sign in to comment.