How do I send a message in Python?
I have connected the SDK and I need to send a message to it:
bridge.platform.sendMessage('game_ready')
But it doesn't work. I connected the SDK using a script in index.html . I see a successful connection in the console.
I'm trying:
window.bridge.platform.sendMessage('game_ready')
global bridge
window.bridge.platform.sendMessage('game_ready')
But none of this works.
Please help me
Browsers do not allow connections to any domain - maybe this is also happening in your case.
When I wanted to download something using a script, some data, a message appeared in the console that it was blocked due to "Access-Control-Allow-Origin".
Check the console to see if you have any error messages.
There are no errors in the console. It's as if the browser just ignores these lines.
I experimented a little, now there is such an error:
Access to internal resource at 'file:///C:/Users/User/Desktop/%D0%9D%D0%BE%D0%B2%D0%B0%D1%8F%20%D0%BF%D0%B0%D0%BF%D0%BA%D0%B0/manifest.json' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, isolated-app, chrome-extension, chrome, https, chrome-untrusted.
This is a safeguard, otherwise every site (with bad intentions/hostile) would read the contents of the disk.
Generally, you cannot read data from domains other than the one from which the WWW
page is launched.
Every browser currently has this blocked downloading from other sources because it was a common way to steal data from WWW sites.
I once tried to unblock it in Firefox
(about:config
) - but I couldn't.
In Chrome
, it helps to run the browser from the terminal with the attribute "--allow-file-access-from-files"
.
(You must first disable all other Chrome
instances).
However, this lowers the security of the system. And when you run the browser with this option, do not visit other WWW sites except the ones you are testing.
You can also run a local small http server
and make queries to it.