Working on making server and client uuid in sync but a challenjour has appeared is good
parent
d6ea697f57
commit
fab2ab97d7
2
pool.go
2
pool.go
|
|
@ -30,7 +30,7 @@ func (p *Pool) Push(id string, conn *websocket.Conn) {
|
|||
p.lock.Lock()
|
||||
p.conns.Store(id, &Conn{ws: *conn})
|
||||
p.lock.Unlock()
|
||||
p.Broadcast(websocket.TextMessage, strings.NewReader(`{"joined":"`+id+`"}`))
|
||||
p.Broadcast(websocket.TextMessage, strings.NewReader(`{"joined":"`+id+`", "uuid":"`+id+`"}`))
|
||||
}
|
||||
|
||||
func (p *Pool) Broadcast(mt int, r io.Reader) error {
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ class RTC {
|
|||
constructor(stream) {
|
||||
this.conn = new RTCPeerConnection(Config.iceConfig);
|
||||
this.conn.onicecandidate = (event) => {
|
||||
if(event.candidate != null) {
|
||||
if (event.candidate != null) {
|
||||
WS.ws.send(JSON.stringify({'ice': event.candidate, 'uuid': Config.getUUID()}));
|
||||
}
|
||||
};
|
||||
|
|
@ -153,27 +153,30 @@ class Entropy {
|
|||
|
||||
static start(isCaller) {
|
||||
Entropy.rtc = new RTC(Entropy.local.stream);
|
||||
if(isCaller) {
|
||||
if (isCaller) {
|
||||
Entropy.rtc.offer(Entropy.createdDescription);
|
||||
}
|
||||
}
|
||||
|
||||
static gotMessageFromServer(message) {
|
||||
if(!Entropy.rtc || !Entropy.rtc.conn) Entropy.start(false);
|
||||
if (!Entropy.rtc || !Entropy.rtc.conn) Entropy.start(false);
|
||||
|
||||
var signal = JSON.parse(message.data);
|
||||
|
||||
// Ignore messages from ourself
|
||||
if(signal.uuid == Config.getUUID()) return;
|
||||
if (signal.uuid == Config.getUUID()) return;
|
||||
|
||||
if(signal.sdp) {
|
||||
if (signal.joined)
|
||||
Log.info("a challenjour has appeared", JSON.stringify(signal));
|
||||
|
||||
if (signal.sdp) {
|
||||
Entropy.rtc.conn.setRemoteDescription(new RTCSessionDescription(signal.sdp)).then(function() {
|
||||
// Only create answers in response to offers
|
||||
if(signal.sdp.type == 'offer') {
|
||||
if (signal.sdp.type == 'offer') {
|
||||
Entropy.rtc.conn.createAnswer().then(Entropy.createdDescription).catch(Log.error);
|
||||
}
|
||||
}).catch(Log.error);
|
||||
} else if(signal.ice) {
|
||||
} else if (signal.ice) {
|
||||
Entropy.rtc.conn.addIceCandidate(new RTCIceCandidate(signal.ice)).catch(Log.error);
|
||||
}
|
||||
}
|
||||
|
|
@ -212,7 +215,7 @@ class Local {
|
|||
video: this.gettype() == "video",
|
||||
audio: this.gettype() == "audio",
|
||||
};
|
||||
if(!navigator.mediaDevices.getUserMedia) {
|
||||
if (!navigator.mediaDevices.getUserMedia) {
|
||||
Log.error('Your browser does not support getUserMedia API');
|
||||
}
|
||||
navigator.mediaDevices.getUserMedia(constraints)
|
||||
|
|
@ -258,7 +261,7 @@ for (var i in ["log", "info", "warn", "error"]) {
|
|||
window.console = console;
|
||||
|
||||
function pageReady() {
|
||||
Config.newUUID();
|
||||
//Config.newUUID();
|
||||
var host = window.location.hostname;
|
||||
if (window.location.port) {
|
||||
host += ":" + window.location.port;
|
||||
|
|
|
|||
Loading…
Reference in New Issue