altv-rpc icon indicating copy to clipboard operation
altv-rpc copied to clipboard

rpc.addWebView() optional naming: server + browser-side named callBrowser(), triggerBrowser()

Open jaeger046 opened this issue 4 years ago • 3 comments

Proposal

Expand rpc.addWebView() to have a second argument, name.

When adding WebViews at client-side, a second optional argument could be passed like this:

rpc.addWebView(animBrowser, 'animBrowser')

Internally, this could then map browser names to individual browsers, allowing individual browsers to be triggered from any context. For example, you could do:

rpc.callBrowser('animBrowser', 'someProcedureInAnimBrowser')
rpc.triggerBrowser('animBrowser', 'someEventInAnimBrowser')

^ from server-side, any browser, or the client. This would greatly improve performance by removing the need to loop through all browsers when calling remotely, i.e. from server-side.

Changes

  • Optional second argument for rpc.addWebView() - name.
  • If optional argument is specified, the name string is mapped to the given browser.
  • callBrowser and triggerBrowser adapted to handle case where browser is string for server, client + browser environment.
  • If either function is called in the client environment and the browser argument is not a string or browser type, it should still throw an error as expected.

jaeger046 avatar Jul 11 '20 12:07 jaeger046

this is a great idea! i will look into implementing this.

micaww avatar Jan 30 '21 21:01 micaww

Proposal

Expand rpc.addWebView() to have a second argument, name.

When adding WebViews at client-side, a second optional argument could be passed like this:

rpc.addWebView(animBrowser, 'animBrowser')

Internally, this could then map browser names to individual browsers, allowing individual browsers to be triggered from any context. For example, you could do:

rpc.callBrowser('animBrowser', 'someProcedureInAnimBrowser')
rpc.triggerBrowser('animBrowser', 'someEventInAnimBrowser')

^ from server-side, any browser, or the client. This would greatly improve performance by removing the need to loop through all browsers when calling remotely, i.e. from server-side.

Changes

  • Optional second argument for rpc.addWebView() - name.
  • If optional argument is specified, the name string is mapped to the given browser.
  • callBrowser and triggerBrowser adapted to handle case where browser is string for server, client + browser environment.
  • If either function is called in the client environment and the browser argument is not a string or browser type, it should still throw an error as expected.

Why run multiple browsers at the same time? When you can run a single browser and render whatever you want on the browser side (react + redux) ?

uncle-ara avatar Mar 31 '22 17:03 uncle-ara

@uncle-ara not sure how this question is relevant to this repo. make your game however you see fit and this library can adapt accordingly.

micaww avatar Mar 31 '22 18:03 micaww