Split out the concept of headless and an archive peer. Add better logging for URL params
This commit is contained in:
@@ -546,6 +546,7 @@ class App {
|
||||
this.posts = [];
|
||||
this.isHeadless = false;
|
||||
this.isBootstrapPeer = false;
|
||||
this.isArchivePeer = false;
|
||||
this.showLog = false;
|
||||
this.markedAvailable = false;
|
||||
this.limitPosts = 50;
|
||||
@@ -1247,73 +1248,21 @@ class App {
|
||||
if (urlParams.has('log')) {
|
||||
this.showInfo();
|
||||
}
|
||||
this.isHeadless = /\bHeadlessChrome\//.test(navigator.userAgent);
|
||||
this.isHeadless = /\bHeadlessChrome\//.test(navigator.userAgent) || urlParams.has('headless');
|
||||
this.isArchivePeer = urlParams.has('archive');
|
||||
this.isBootstrapPeer = urlParams.has("bootstrap");
|
||||
if (this.isBootstrapPeer) {
|
||||
console.log.apply(null, log(`This is a bootstrap peer`));
|
||||
;
|
||||
console.log(`[headless]${this.isHeadless} [archive] ${this.isArchivePeer} [bootstrap] ${this.isBootstrapPeer}`);
|
||||
let limitPostsParam = urlParams.get('limitPosts');
|
||||
if (limitPostsParam) {
|
||||
this.limitPosts = parseInt(limitPostsParam);
|
||||
}
|
||||
this.peerID = this.getPeerID();
|
||||
this.peername = this.getPeername();
|
||||
this.userID = this.getUserID();
|
||||
this.username = this.getUsername();
|
||||
this.sync.setUserID(this.userID);
|
||||
this.sync.setArchive(this.isArchivePeer);
|
||||
this.connect();
|
||||
// this.registerRPCs();
|
||||
// this.testPeerManager();
|
||||
// let peer: RTCPeerConnection | null = null;
|
||||
// // if (window.RTCPeerConnection) {
|
||||
// peer = new RTCPeerConnection({
|
||||
// iceServers: [
|
||||
// { urls: "stun:ddln.app" },
|
||||
// // { urls: "turn:ddln.app", username: "a", credential: "b" },
|
||||
// { urls: "stun:stun.l.google.com" }, // keeping this for now as my STUN server is not return ipv6
|
||||
// // { urls: "stun:stun1.l.google.com" },
|
||||
// // { urls: "stun:stun2.l.google.com" },
|
||||
// // { urls: "stun:stun3.l.google.com" },
|
||||
// // { urls: "stun:stun4.l.google.com" },
|
||||
// ]
|
||||
// });
|
||||
// peer.createDataChannel('boop');
|
||||
// peer.onicecandidate = ({ candidate }) => { log(`WRTC:${candidate?.address} ${candidate?.protocol} ${candidate?.type} ${(candidate as any)?.url}`) };
|
||||
// peer.onnegotiationneeded = async (event) => {
|
||||
// console.log.apply(null, log("on negotiation needed fired"));;
|
||||
// let makingOffer = false;
|
||||
// try {
|
||||
// makingOffer = true;
|
||||
// await peer.setLocalDescription();
|
||||
// let IDsToSync = this.following;
|
||||
// if (this.router.route === App.Route.USER) {
|
||||
// IDsToSync = new Set([this.router.userID]);
|
||||
// }
|
||||
// if (!peer.localDescription) {
|
||||
// return;
|
||||
// }
|
||||
// // this.websocket = new wsConnection(this.userID, this.peerID, IDsToSync, peer.localDescription);
|
||||
// // log(peer.localDescription.type + ":" + peer.localDescription.sdp);
|
||||
// // this.initOffline(this.websocket);
|
||||
// // this.websocket?.sendWebRTCDescription(peer.localDescription);
|
||||
// } catch (err) {
|
||||
// console.error(err);
|
||||
// } finally {
|
||||
// makingOffer = false;
|
||||
// }
|
||||
// }
|
||||
// peer.createOffer().then((description)=>{
|
||||
// peer.setLocalDescription(description)
|
||||
// console.log.apply(null, log("RTC: " + description.sdp + description.type));;
|
||||
// });
|
||||
// }
|
||||
// await this.exportPostsForUser('b38b623c-c3fa-4351-9cab-50233c99fa4e');
|
||||
// Get initial state and route from URL and user agent etc
|
||||
// Set local state (userid etc) based on that.
|
||||
// Init libraries
|
||||
// Render
|
||||
// Load all images async
|
||||
// Start the process of figuring out what posts we need
|
||||
// Download posts once all current images are loaded
|
||||
// window.resizeTo(645, 900);
|
||||
// this.initLogo()
|
||||
this.getRoute();
|
||||
if (this.router.route === App.Route.CONNECT) {
|
||||
console.log.apply(null, log('connect', this.router.userID));
|
||||
@@ -1323,11 +1272,6 @@ class App {
|
||||
await this.initDB();
|
||||
this.connectURL = `${document.location.origin}/connect/${this.userID}`;
|
||||
document.getElementById('connectURL').innerHTML = `<a href="${this.connectURL}">connect</a>`;
|
||||
this.isHeadless = urlParams.has('headless');
|
||||
let limitPostsParam = urlParams.get('limitPosts');
|
||||
if (limitPostsParam) {
|
||||
this.limitPosts = parseInt(limitPostsParam);
|
||||
}
|
||||
let time = 0;
|
||||
let delta = 0;
|
||||
// let isPersisted = await navigator?.storage?.persisted();
|
||||
|
||||
Reference in New Issue
Block a user