Internet Browser: Difference between revisions
Info about how use websessions |
|||
Line 271: | Line 271: | ||
* Ack: Verifies that message_count is not already 0, then decrements it. Then cur_size is decreased by the u32 loaded from msgcontent+0. | * Ack: Verifies that message_count is not already 0, then decrements it. Then cur_size is decreased by the u32 loaded from msgcontent+0. | ||
* 0x0: Does some validation. Copies the first 8-bytes from the header to the user [[#SessionMessage]]. Reads the message content into the user [[#SessionMessage]], when contentsize is non-zero. Then sends an Ack with the storage size. | * 0x0: Does some validation. Copies the first 8-bytes from the header to the user [[#SessionMessage]]. Reads the message content into the user [[#SessionMessage]], when contentsize is non-zero. Then sends an Ack with the storage size. | ||
Next info was tested in 9.0.0 | |||
In the js side, there is a method called <code>window.nx.sendMessage(arg)</code> that sends data to the native side, this method returns a boolean indicating if sending was succesful and accepts a string as an argument. The string is encoded like a C null terminated string in the message content. For receive messages from native part, there is a dom event called <code>message</code> which is dispatched when a message arrives. The event can be listened using <code>window.nx.addEventListener("message", callback)</code> being callback a function which first parameter is like a dom event arg and contains a member called <code>data</code> which contains the string decoded from the arrived message | |||
If messages aren't acked by the native part, js side will not longer receive messages. Ack to web applet '''must''' have 4 bytes after the message content or will crash. | |||
==== SessionMessage ==== | ==== SessionMessage ==== | ||
Line 286: | Line 292: | ||
| Size from header | | Size from header | ||
| Message content | | Message content | ||
|- | |||
| After message content | |||
| 0x4 if message is ack, 0x0 otherwise | |||
| Padding | |||
|} | |} | ||
Line 320: | Line 330: | ||
|- | |- | ||
| 0x1000 | | 0x1000 | ||
| | | 0xc | ||
| Ack. Content: first u32 is the entire storage size of the message being acked, | | Ack. Content: first u32 is the entire storage size of the message being acked, the rest is not used. | ||
|} | |} | ||