Skip to content

Instantly share code, notes, and snippets.

@kylewelsby
Last active December 28, 2015 03:29
Show Gist options
  • Save kylewelsby/7435468 to your computer and use it in GitHub Desktop.
Save kylewelsby/7435468 to your computer and use it in GitHub Desktop.
{
"config": {
"errorMessages": [],
"channelToken": "AHRlWrpa5tISngbssBEDidkSwqZQnG2e_a7mSmX5K8gJheKfCdoGowKIJdHPSKyyk-xwwN0l8rF4WjWM9rBTDnJ4ais6AvULM4HqrlnAiDu4Mapm1X6Csw8",
"me": "65499267",
"roomKey": "61879062",
"roomLink": "https: //apprtc.appspot.com/?r=61879062",
"initiator": 0,
"pcConfig": {
"iceServers": [
{
"url": "stun: stun.l.google.com: 19302"
}
]
},
"pcConstraints": {
"optional": [
{
"DtlsSrtpKeyAgreement": true
}
]
},
"offerConstraints": {
"optional": [],
"mandatory": {}
},
"mediaConstraints": {
"audio": true,
"video": true
},
"turnUrl": "https: //computeengineondemand.appspot.com/turn?username=65499267&key=4080218913",
"stereo": false,
"audio_send_codec": "",
"audio_receive_codec": "opus/48000"
}
}
package hello
import (
"net/http"
"html/template"
"encoding/json"
"appengine"
"appengine/channel"
)
func init() {
http.HandleFunc("/", handler)
}
var mainTemplate = template.Must(template.ParseFiles("index.html"))
type Config struct {
Token string `json:"token"`
RoomLink string `jsoin:"roomLink"`
Initiator int
PgConfig struct {
IceServers map[string]string `json:"iceServers"`
}
}
func handler(w http.ResponseWriter, r *http.Request) {
c := appengine.NewContext(r)
key := "test"
room_link := r.RequestURI
token, err := channel.Create(c, key)
if err != nil {
http.Error(w, "Could not create Channel", http.StatusInternalServerError)
c.Errorf("channel.Create: %v", err)
return
}
config := Config {
Token: token,
RoomLink: room_link,
Initiator: 1,
// PgConfig: {
// IceServers: []string{"test"},
// },
}
c, err := json.MarshalIndent(config, "config")
if err != nil {
http.Error(w, "Failed to encode JSON", http.StatusInternalServerError)
}
err = mainTemplate.Execute(w,c)
if err != nil {
c.Errorf("mainTemplate: %v", err)
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Simple Hangout</title>
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<link rel="cononical" href="{{ .room_link }}">
<link rel="stylesheet" href="css/main.css">
</head>
<body>
<div id="card">
<div id="local">
<video id="localVideo" autoplay="autoplay" muted="true"></video>
</div>
<div id="remote">
<video id="remoteVideo" autoplay="autoplay"></video>
<div id="mini">
<video id="miniVideo" autoplay="autoplay" muted="true"></video>
</div>
</div>
</div>
<h5>Status Log</h5>
<pre id="status">
</pre>
<div id="infoDiv"></div>
<script type="text/javascript" src="/_ah/channel/jsapi"></script>
<script>
var config;
config = {
"errorMessages": [],
"channelToken": "AHRlWrpa5tISngbssBEDidkSwqZQnG2e_a7mSmX5K8gJheKfCdoGowKIJdHPSKyyk-xwwN0l8rF4WjWM9rBTDnJ4ais6AvULM4HqrlnAiDu4Mapm1X6Csw8",
"me": "65499267",
"roomKey": "61879062",
"roomLink": "https: //apprtc.appspot.com/?r=61879062",
"initiator": 0,
"pcConfig": {
"iceServers": [
{
"url": "stun: stun.l.google.com: 19302"
}
]
},
"pcConstraints": {
"optional": [
{
"DtlsSrtpKeyAgreement": true
}
]
},
"offerConstraints": {
"optional": [],
"mandatory": {}
},
"mediaConstraints": {
"audio": true,
"video": true
},
"turnUrl": "https: //computeengineondemand.appspot.com/turn?username=65499267&key=4080218913",
"stereo": false,
"audio_send_codec": "",
"audio_receive_codec": "opus/48000"
};
//config.channelToken = '{{ .token }}';
//config.initiator = '{{ .initiator }}';
//config.roomLink = '{{ .room_link }}';
//config.pgConfig = '{{ .pg_config }}';
</script>
<script src="js/main.js"></script>
<script>
setTimeout( function () {
initalize();
},1);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment