Post syncing logic is wokting. As expected datachannels fail to send posts above a certain size. Need to implement chunking next.
This commit is contained in:
36
src/main2.ts
36
src/main2.ts
@@ -755,10 +755,14 @@ class App {
|
||||
this.sync.addUserPeer(userID, sendingPeerID);
|
||||
if (this.sync.shouldSyncUserID(userID)) {
|
||||
let postIDs = await this.peerManager?.rpc.getPostIDsForUser(sendingPeerID, userID);
|
||||
console.log.apply(null, log(`[app] announceUsers response, gotPostIDs`, postIDs));
|
||||
let neededPosts = await this.sync.checkPostIds(userID, sendingPeerID, postIDs);
|
||||
// console.log.apply(null, log(`[app] announceUsers response, gotPostIDs`, postIDs));
|
||||
let neededPostIDs = await this.sync.checkPostIds(userID, sendingPeerID, postIDs);
|
||||
// console.log.apply(null, log(`[app] announceUsers needed posts`, neededPostIDs));
|
||||
|
||||
console.log.apply(null, log(`[app] announceUsers needed posts`, neededPosts));
|
||||
if (neededPostIDs.length > 0) {
|
||||
let neededPosts = await this.peerManager?.rpc.getPostsForUser(sendingPeerID, this.peerID, userID, neededPostIDs);
|
||||
console.log(neededPosts);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
@@ -806,17 +810,35 @@ class App {
|
||||
this.announceUser_rpc_response(sendingPeerID, userIDs);
|
||||
});
|
||||
|
||||
this.peerManager.registerRPC('getPeersForUser', (userID: any) => {
|
||||
this.peerManager.registerRPC('getPeersForUser', (userID: string) => {
|
||||
return [1, 2, 3, 4, 5];
|
||||
});
|
||||
|
||||
|
||||
this.peerManager.registerRPC('getPostIDsForUser', async (userID: any) => {
|
||||
this.peerManager.registerRPC('getPostIDsForUser', async (userID: string) => {
|
||||
let postIDs = await this.sync.getPostIdsForUser(userID);
|
||||
|
||||
return postIDs;
|
||||
if (postIDs) {
|
||||
return postIDs;
|
||||
}
|
||||
});
|
||||
|
||||
this.peerManager.registerRPC('getPostsForUser', async (requestingPeerID:string, userID:string, postIDs: string[]) => {
|
||||
let posts = await this.sync.getPostsForUser(userID, postIDs);
|
||||
|
||||
|
||||
for (let post of posts) {
|
||||
this.peerManager?.rpc.sendPostForUser(requestingPeerID, userID, post);
|
||||
}
|
||||
// return posts;
|
||||
|
||||
// return postIDs;
|
||||
});
|
||||
|
||||
this.peerManager.registerRPC('sendPostForUser', async (requestingPeerID:string, userID:string, post:string) => {
|
||||
console.log.apply(null, log(`[app] sendPostForUser to [${logID(requestingPeerID)}] `, userID, post));
|
||||
});
|
||||
|
||||
|
||||
await this.peerManager.connect();
|
||||
console.log.apply(null, log("*************** after peerManager.connect"));;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user