micaww / altv-rpc

A universal, asynchronous RPC implementation for alt:V
19 stars 11 forks source link

CEF to client doesn't work #5

Closed xtance closed 3 years ago

xtance commented 3 years ago

Works fine in RAGE:MP but not in AltV. Nothing happens when rpc.callClient

Update: the fix is: rpc.addWebView(browser); on clientside (as found in updated readme)

micaww commented 3 years ago

Hey @xtance do you have any reproducible example? I am using this heavily in a large project with no issues.

One major difference on this version as opposed to RageMP's implementation is that you have to specify a matching namespace in each context.

For example:

const rpc = require('altv-rpc');

rpc.init('myproject');

// now use it freely
rpc.callClient('blahblah').then(console.log);
xtance commented 3 years ago

Oops, sorry it's my bad, I forgot to add webview, probably that was the reason. Can I re-use the same window.rpc after it was set like this? In other .js files in the same "browser"?

        <script src="./lib/altv-rpc-browser.js"></script>
        <script type="text/javascript">
            rpc.init('platee');
        </script>
micaww commented 3 years ago

No problem! Glad it worked :)

Yes of course, as long as all rpc calls happen after the namespace has already been set, any file should be able to use that global rpc instance.

xtance commented 3 years ago

Nice, thanks for response and for this library. I'm going to close issue as the problem was resolved. :з