This document describes a proposed extension to the
<invoke> element. It would enable SCXML running on Web clients to open a virtual connection to a remote system to send and/or receive events. There is no requirement that the connection be symmetrical, and the underlying implementation doesn't have to be a single persistent connection.
The communication protocol and data encoding are defined by the type of invoke; in fact, the type determines whether it is a normal invocation or a connection. JSSC provides the event-stream type by default, and a two-way connection using WebSockets should be available later.
These attributes are added to
|Name||Required||Type||Default value||Valid values||Description|
|target||if using a connection type, but never both of those||URI||none||Any value accepted by the type implementation||The connection will be opened there.|
|targetexpr||Vale expression||none||Evaluates when the |
src attribute is forbidden when using a connection type.
Specific connection types may use children (for example
content) to specify initialization and authentication data. By default, the only useful children are:
paramelements with the
The connection is opened when an invoked session would be started, i.e. when its source state becomes active after a macrostep. The connection is closed when the source state is exited (it may also be closed from the other side for any reason).
done.invoke.idevent in the external queue. It must not reconnect unless the element's source state is re-entered.
While the connection is open:
<send>elements with their
typeattribute set to the type of the connection. Moreover, if the
autoforwardattribute was present, all events processed by the interpreter must be sent over the connection at the time they are dequeued.
invokeelements, as long as the implementation pretends to have one virtual connection for every connection-like
error.execution.parsefailedmust be placed in the internal queue and the event's data field must be left empty.
finalizeelement is present but empty, and the event data can be parsed as key-value pairs, any names (in the namelist) or locations (in params) specified in the connection and present as properties of the event's data must be updated with the values values in the event's data. If instead the
finalizeelement contains executable content, that content is executed. Either action must occur when the event is dequeued, as usual.
invoke element's source state is exited, the connection is closed. When relevant, the other side should be notified according to the actual protocol used. No
done event is generated by the interpreter when the connection is closed in this way.
As soon as a connection is closed for whatever reason, the interpreter must not send anymore events over it and it must ignore any further events that it receives from it.
Invoke types in JSSC are represented by properties of the
SCxml.invokeTypes object. Adding a new type, whether connection-like or normal invokes, simply means adding a new object. In the case of connection-like types, instead of an
instantiate method, the object should have an
open method with the same arguments, except that the first argument passed to it will be the target instead of the source.