Can JSON objects be sent from JavaScript to a C# server using a Peer to Peer network? Is there an alternative method for sending data in real-time to a C# server? Below are the functions from my JavaScript code:
Peer To Peer Code
function establishPeerServer(evt) {
console.log('Creating new peer server');
createNewPeer = true;
evt.preventDefault();
myPeerId = document.getElementById('newpeerid').value;
var peerNetTemp = document.getElementById('peernet').value;
peerNet = JSON.parse(peerNetTemp);
// Destroy default peer before creating a new one
peer.disconnect();
peer.destroy();
// Show new peer credentials. Hide default IP address
document.getElementById("connectionopen").style.display = 'none';
document.getElementById("newpeercreated").style.display = 'block';
}
function sendToPeer(evt, data) {
var dataToSend = {"event": evt, "data": data};
peer_connections.forEach(function(connection) {
connection.send(dataToSend);
});
}
Skeleton Tracking Code
function initializeSkeletonTracking() {
console.log('Initiating skeleton tracking');
var skeletonCanvas = document.getElementById('skeleton-canvas');
var skeletonContext = skeletonCanvas.getContext('2d');
resetCanvas('depth');
canvasState = 'depth';
if(kinect.open()) {
kinect.on('bodyFrame', function(bodyFrame){
if(sendAllBodies) {
sendToPeer('bodyFrame', bodyFrame);
if (doRecord) {
bodyFrame.record_startime = recordStartTime;
bodyFrame.record_timestamp = Date.now() - recordStartTime;
bodyChunks.push(bodyFrame);
}
}
});
kinect.openBodyReader();
}
}