jsexecutor class : Notice(class,string) method

Description

Assigns a handler to the "Notice" event.

Syntax

instance.Notice(class handleClass, string signature)

Arguments

ClassNameDescription
classhandleClassAn instance with the handler as the member.
stringsignatureSignature of the handler.

Return value

ClassDescription
switchAn instance to control handler execution.

Sample code

Suppose you have the following class definition.

1:

class handle

2:

open method void NHandler(dictionary dic)

3:

switch sw = dic.Switch;

4:

string data = dic.Data;

5:

endmethod

6:

endclass

Handler assignment is as follows.

1:

jsexecutor jse; // For Main-browser

2:

handle h = new handle();

3:

switch sw = jse.Notice(h,"Nhandler(dictionary)");

4:

sw.Start();

Notes

The "Notice" event is fired when you call the following function in JavaScript.


window.cooker.external.Notice(token, 'A string data which will be passed to the Rice.');


The argument of the JavaScript function will be passed to the event handler on the Rice.


window.cooker.external is a host object exposed to the JavaScript environment for communication between JavaScript and Rice.


The handler for the "Notice" event must be an open method with one argument of the dictionary class.

In other words, if the method name of the handler is "handlerName", the definition of the handler is as follows.


open method void handlerName(dictionary dic)

...

endmethod


In this case, the signature of the handler specify by the second argument is "handlerName(dictionary)".

Host objects with the following names are exposed to JavaScript.


window.cooker.external

window.chrome.webview.hostObjects.external


The first object is alias of the second. it works the same whichever you use. Here, we explain the window.cooker.external as an example.

window.cooker.external has the following asynchronous functions.


window.cooker.external.GetData(token)

Receives a string data from Rice in JavaScript.

window.cooker.external.SetData(token,data)

Sends a string data from JavaScript to Rice.

window.cooker.external.Notice(token,data)

Fires Rice's jsexecutor.Notice event from JavaScript.


See JavaScript extensions. for host objects.


The dictionary passed to the handler has the following key/value pairs.

keyvalue - classvalue - description
SenderbrowserThe origin of the event.
SwitchswitchThe switch returned by the handler assignment.
DatastringThe data argument of window.cooker.external.Notice(token,data).

The handler runs in its own thread.

Links for reference

None.

Copyright © Cooker All rights reserved.