Changes

Jump to navigation Jump to search
940 bytes added ,  00:02, 24 June 2020
Line 274: Line 274:  
This is for sending/receiving [[#SessionMessage]]s via applet Interactive storage.
 
This is for sending/receiving [[#SessionMessage]]s via applet Interactive storage.
   −
During state init, max_messages is set to 0xA and max_size is set to 0x5000, with message_count=0 and cur_size=0.
+
During state init, max_messages is set to 0xA ([7.0.0+] 0x10), with message_count=0 and cur_size=0. [5.0.0-5.1.0] max_size is set to 0x5000. [7.0.0+] Two queues are used for message_count/cur_size: first one is for BrowserEngineContent (max_size 0x8000 is used), the second one is for non-BrowserEngineContent (max_size 0x1000 is used).
   −
When sending messages, there has to be an available message slot available (<code>max_messages!=message_count</code>), and there has to be enough space avilable (<code>msghdr_contentsize+0x10 + cur_size <= max_size</code>). After pushing the storage, message_count is incremented and cur_size is increased by <code>msghdr_contentsize+0x10</code>.
+
When sending messages, there has to be an available message slot available (<code>max_messages!=message_count</code>), and there has to be enough space available (<code>msghdr_contentsize+0x10 + cur_size <= max_size</code>). After pushing the storage, message_count is incremented and cur_size is increased by <code>msghdr_contentsize+0x10</code>.
    
When receiving messages, it will repeatedly pop Interactive output storage until no more are available. If the ID is not 0x1000/0x0, the message is ignored. Otherwise:
 
When receiving messages, it will repeatedly pop Interactive output storage until no more are available. If the ID is not 0x1000/0x0, the message is ignored. Otherwise:
Line 284: Line 284:  
Next info was tested in 9.0.0
 
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
+
In the js side (which is only available when enabled via the JsExtensionEnabled TLV), 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 successful 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.
+
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 the applet will Abort.
    
==== SessionMessage ====
 
==== SessionMessage ====
Line 317: Line 317:  
| 0x0
 
| 0x0
 
| 0x4
 
| 0x4
| Message ID
+
| Message Kind
 
|-
 
|-
 
| 0x4
 
| 0x4
 
| 0x4
 
| 0x4
| Content size following the header.
+
| Data size following the header.
 
|-
 
|-
 
| 0x8
 
| 0x8
Line 328: Line 328:  
|}
 
|}
   −
==== IDs ====
+
==== WebSessionSendMessageKind ====
 +
This is "nn::web::detail::WebSessionSendMessageKind".
 +
 
 
{| class="wikitable" border="1"
 
{| class="wikitable" border="1"
 
|-
 
|-
Line 337: Line 339:  
| 0x0
 
| 0x0
 
| Arbitrary
 
| Arbitrary
| Arbitrary content. Used to communicate with the applet via JsExtensions used by the Js being run by the applet on the current page.
+
| BrowserEngine Content, NUL-terminated string. Used to communicate with the applet via JsExtensions used by the Js being run by the applet on the current page.
 +
|-
 +
| 0x100
 +
| 0x0
 +
| SystemMessage Appear. Requests the applet to Appear, this is only needed with [[#WebSessionBootMode]] AllForegroundInitiallyHidden.
 
|-
 
|-
 
| 0x1000
 
| 0x1000
| 0xc
+
| 0xC
 
| Ack. Content: first u32 is the entire storage size of the message being acked, the rest is not used.
 
| Ack. Content: first u32 is the entire storage size of the message being acked, the rest is not used.
 +
|}
 +
 +
==== WebSessionReceiveMessageKind ====
 +
This is "nn::web::detail::WebSessionReceiveMessageKind".
 +
 +
{| class="wikitable" border="1"
 +
|-
 +
!  ID
 +
!  Content size
 +
!  Description
 +
|-
 +
| 0x0
 +
| Arbitrary
 +
| BrowserEngine Content, see [[#WebSessionSendMessageKind]].
 +
|-
 +
| 0x1000
 +
| 0xC
 +
| Ack BrowserEngine
 +
|-
 +
| 0x1001
 +
| 0xC
 +
| Ack SystemMessage
 
|}
 
|}
   Line 1,126: Line 1,154:     
==== WebSessionBootMode ====
 
==== WebSessionBootMode ====
 +
This is "nn::web::WebSessionBootMode".
 +
 
{| class="wikitable" border="1"
 
{| class="wikitable" border="1"
 
|-
 
|-
Line 1,134: Line 1,164:  
| 0
 
| 0
 
|  
 
|  
| Normal (AllForeground)
+
| Normal/default (AllForeground)
 
|-
 
|-
 
| 1
 
| 1

Navigation menu