Add browser to CEF->client callback info

This commit is contained in:
micah 2019-03-06 11:55:52 -05:00
parent 4637d668b5
commit ca36777813
2 changed files with 3 additions and 2 deletions

1
src/defs.d.ts vendored
View File

@ -19,6 +19,7 @@ declare interface ProcedureListenerInfo {
environment: string; environment: string;
id?: string; id?: string;
player?: Player; player?: Player;
browser?: Browser;
} }
declare interface Event { declare interface Event {

View File

@ -26,7 +26,6 @@ if(!glob[PROCESS_EVENT]){
environment: data.fenv || data.env environment: data.fenv || data.env
}; };
if(environment === "server") info.player = player as Player; if(environment === "server") info.player = player as Player;
const promise = callProcedure(data.name, data.args, info);
const part = { const part = {
ret: 1, ret: 1,
id: data.id, id: data.id,
@ -42,6 +41,7 @@ if(!glob[PROCESS_EVENT]){
ret = ev => mp.events.callRemote(PROCESS_EVENT, util.stringifyData(ev)); ret = ev => mp.events.callRemote(PROCESS_EVENT, util.stringifyData(ev));
}else if(data.env === "cef"){ }else if(data.env === "cef"){
const browser = data.b && glob.__rpcBrowsers[data.b]; const browser = data.b && glob.__rpcBrowsers[data.b];
info.browser = browser;
ret = ev => browser && util.isBrowserValid(browser) && passEventToBrowser(browser, ev, true); ret = ev => browser && util.isBrowserValid(browser) && passEventToBrowser(browser, ev, true);
} }
break; break;
@ -50,7 +50,7 @@ if(!glob[PROCESS_EVENT]){
ret = ev => mp.trigger(PROCESS_EVENT, util.stringifyData(ev)); ret = ev => mp.trigger(PROCESS_EVENT, util.stringifyData(ev));
} }
} }
if(ret) promise.then(res => ret({ ...part, res })).catch(err => ret({ ...part, err })); if(ret) callProcedure(data.name, data.args, info).then(res => ret({ ...part, res })).catch(err => ret({ ...part, err }));
}else if(data.ret){ // a previously called remote procedure has returned }else if(data.ret){ // a previously called remote procedure has returned
const info = glob.__rpcPending[data.id]; const info = glob.__rpcPending[data.id];
if(environment === "server" && info.player !== player) return; if(environment === "server" && info.player !== player) return;