This commit is contained in:
giongto35 2019-04-10 00:02:10 +08:00
parent 9bde5b14dd
commit 5cf49fdebf
2 changed files with 3 additions and 4 deletions

View file

@ -145,7 +145,8 @@ func ws(w http.ResponseWriter, r *http.Request) {
break
}
// connectivity
// SDP connection initializations follows WebRTC convention
// https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API/Protocols
switch req.ID {
case "ping":
gameName = req.Data
@ -165,6 +166,7 @@ func ws(w http.ResponseWriter, r *http.Request) {
res.Data = localSession
case "candidate":
// Unuse code
hi := pionRTC.ICECandidateInit{}
err = json.Unmarshal([]byte(req.Data), &hi)
if err != nil {

View file

@ -73,10 +73,8 @@ function startGame() {
else if (pc.iceConnectionState === "disconnected") {
endInput();
}
}
// stream channel
pc.ontrack = function (event) {
log("New stream, yay!");
@ -94,7 +92,6 @@ function startGame() {
conn.send(JSON.stringify({"id": "sdp", "data": session}));
} else {
console.log(JSON.stringify(event.candidate));
// conn.send(JSON.stringify({"id": "candidate", "data": JSON.stringify(event.candidate)}));
}
}