JSSCxml connection-like <invoke> extension

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.

Attribute detail

These attributes are added to <invoke>:
NameRequiredTypeDefault valueValid valuesDescription
targetif using a connection type, but never both of thoseURInoneAny value accepted by the type implementationThe connection will be opened there.
targetexprVale expressionnoneEvaluates when the <invoke> element is executed, used as if there had been a target attribute with the resulting value.

Moreover, the src attribute is forbidden when using a connection type.

Children

Specific connection types may use children (for example param, jssc:header and content) to specify initialization and authentication data. By default, the only useful children are:

Behavior

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).

While the connection is open:

When the 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.

Definition in JSSC

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.