Skip to content

Commit

Permalink
Add getIds function
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastienCozeDev committed Dec 14, 2023
1 parent 82c8b5a commit 9152e09
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion pod/peer_to_peer/static/peer_to_peer/js/p2p-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ let firstTime = false;

function startConnect(options) {
let uuid = crypto.randomUUID();
peer = new Peer(`${videoId}-${uuid}`, options);
peer = new Peer(`${videoId}__ID__${uuid}`, options);
console.log("Peer:", peer);

if (false) { // TODO Delete this test | Set true for sender
Expand All @@ -34,6 +34,27 @@ function startConnect(options) {
});
}

/**
* Get the peer identifiers.
*/
async function getIds() {
console.log('[p2p-script.js] getIds()');
let idList = [];
let postData = {
'url': videoId,
};
// TODO Update the URL
fetch('http://localhost:9090/peer-to-peer/get-ids/', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(postData),
}).then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));
}

async function storeUrlsId() {
console.log('[p2p-script.js] storeUrlsId()');
let fetch_status;
Expand Down

0 comments on commit 9152e09

Please sign in to comment.