1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-24 12:13:16 +00:00

Many improvements.

This commit is contained in:
Ylian Saint-Hilaire
2018-02-11 21:11:58 -08:00
parent 508646044e
commit 4b5c77b4fd
127 changed files with 51725 additions and 35030 deletions

View File

@@ -17,7 +17,7 @@
function start()
{
debug("Connecting signaling channel...");
wsocket = new WebSocket("ws://127.0.0.1:8585/control");
wsocket = new WebSocket("ws://192.168.5.128:8585/control");
wsocket.binaryType = "arraybuffer";
wsocket.onopen = function (evt)
{
@@ -33,7 +33,7 @@
debug("Received WebRTC Offer...");
var ax = null;
if (typeof mozRTCSessionDescription !== 'undefined') { ax = new mozRTCSessionDescription({ type: "answer", sdp: cmd.data }) } else { ax = new RTCSessionDescription({ type: "answer", sdp: cmd.data }) }
if (typeof mozRTCSessionDescription !== 'undefined') { ax = new mozRTCSessionDescription({ type: "offer", sdp: cmd.data }) } else { ax = new RTCSessionDescription({ type: "offer", sdp: cmd.data }) }
connection.setRemoteDescription(ax, onSetRemoteDescriptionDone, onError);
}
}
@@ -41,7 +41,7 @@
function onSetRemoteDescriptionDone()
{
//connection.createAnswer(onAnswerDone, onError);
connection.createAnswer(onAnswerDone, onError);
}
function onAnswerDone(answer)
{
@@ -61,13 +61,7 @@
connection.ondatachannel = onDataChannel
connection.onicecandidate = onIceCandidate;
datachannel = connection.createDataChannel("browserDataChannel", {});
datachannel.onmessage = function (event) { debug("Remote: " + event.data); };
datachannel.onopen = function () { debug("browserDataChannel Connected."); };
datachannel.onclose = function (event) { debug("DataChannel was closed by remote"); }
connection.createOffer(onOfferDone, onError, { mandatory: { OfferToReceiveAudio: false, OfferToReceiveVideo: false } });
connection.oniceconnectionstatechange = function () { if (connection != null) { if ((connection.iceConnectionState == 'disconnected') || (connection.iceConnectionState == 'failed')) { debug("WTF Happened?"); } } }
}
function onOfferDone(offer)
{
@@ -83,15 +77,15 @@
datachannel.binaryType = "arraybuffer";
datachannel.onmessage = function (msg)
{
try
{
datachannel.send(msg.data.byteLength.toString());
}
catch(e)
{
debug(e.toString());
debug(msg.data.toString());
}
//try
//{
// datachannel.send(msg.data.byteLength.toString() + 'bytes of ' + msg.data[0].toString());
//}
//catch(e)
//{
// debug(e.toString());
// //debug(msg.data.toString());
//}
};
}