request post ids for users that match users we follow when peers announce users they know about. Fix for RPCs being async on the remote end. Check returned postIDs to see if we need any posts from a peer.
This commit is contained in:
@@ -390,17 +390,19 @@ export class PeerManager {
|
||||
return;
|
||||
}
|
||||
|
||||
return await peer.call(functionName, args);
|
||||
let returnValues = await peer.call(functionName, args);
|
||||
return returnValues;
|
||||
}
|
||||
|
||||
callFromRemote(functionName: string, args: any) {
|
||||
async callFromRemote(functionName: string, args: any) {
|
||||
let func = this.RPC_remote.get(functionName);
|
||||
|
||||
if (!func) {
|
||||
throw new Error(`callFromRemote: got RPC we don't know about: ${functionName}, ${args}`);
|
||||
}
|
||||
|
||||
return func.apply(null, args);
|
||||
let returnValues = await func.apply(null, args);
|
||||
return returnValues;
|
||||
}
|
||||
|
||||
registerRPC(functionName: string, func: Function) {
|
||||
@@ -449,12 +451,13 @@ class PeerConnection {
|
||||
private isSettingRemoteAnswerPending: boolean = false;
|
||||
private polite = true;
|
||||
private webRTCSuperlog = false;
|
||||
private dataChannelSuperlog = false;
|
||||
private dataChannelSuperlog = true;
|
||||
messageSuperlog: boolean = true;
|
||||
rpcSuperlog: boolean = false;
|
||||
pendingRPCs: Map<
|
||||
string,
|
||||
{ resolve: Function; reject: Function; functionName: string }
|
||||
> = new Map();
|
||||
messageSuperlog: boolean = true;
|
||||
connectionPromise: { resolve: (value?: unknown) => void; reject: (reason?: any) => void; } | null = null;
|
||||
|
||||
// private makingOffer:boolean = false;
|
||||
@@ -473,7 +476,6 @@ class PeerConnection {
|
||||
// { urls: "stun:stun4.l.google.com" },
|
||||
],
|
||||
};
|
||||
rpcSuperlog: boolean = true;
|
||||
|
||||
|
||||
async RPCHandler(message: any) {
|
||||
@@ -729,7 +731,7 @@ class PeerConnection {
|
||||
return promise;
|
||||
}
|
||||
|
||||
onMessage(messageJSON: any) {
|
||||
async onMessage(messageJSON: any) {
|
||||
|
||||
let message: any = {};
|
||||
try {
|
||||
@@ -755,10 +757,14 @@ class PeerConnection {
|
||||
|
||||
if (type === "rpc_call") {
|
||||
|
||||
this.rpcSuperlog && console.log.apply(null, log(`[${logID(this.remotePeerID)}]->[rpc][${logID(this.peerManager.peerID)}] response: `,message.function_name, message.transaction_id, JSON.stringify(message.args, null, 2)));
|
||||
this.rpcSuperlog && console.log.apply(null, log(`[${logID(this.remotePeerID)}]->[rpc][${logID(this.peerManager.peerID)}] call: `,message.function_name, message.transaction_id, JSON.stringify(message.args, null, 2)));
|
||||
|
||||
|
||||
let response = await this.peerManager.callFromRemote(message.function_name, message.args);
|
||||
|
||||
this.rpcSuperlog && console.log.apply(null, log(`[rpc] call: response:`, response));
|
||||
|
||||
|
||||
let response = this.peerManager.callFromRemote(message.function_name, message.args);
|
||||
|
||||
if (response === undefined) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user