summaryrefslogtreecommitdiffstats
path: root/test/uscxml/test-communication.scxml
blob: 2cba08ebc0aaef76fc833daeb44c76ef389af777 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<scxml datamodel="ecmascript" initial="start" binding="late" name="foo">
	<script src="http://uscxml.tk.informatik.tu-darmstadt.de/scripts/dump.js" />

	<state id="start">	
		<!-- Setup datamodel, print environment and send ourself an event to transition to next state -->

		<datamodel>
			<!--data id="invokeconfig">
				<invoker id="scxml" name="http://www.w3.org/TR/scxml/" location="_runtime" />
			</data -->
			<data id="foo" expr="'this is the foo data'" />
			<data id="bar" expr="'this is the bar data'" />
		</datamodel>
		<onentry>
			<log expr="'basichttp listening as ' + _ioprocessors['basichttp'].location" />
			<log expr="'Entered step1'" />
			<log expr="'Sending ourself an event with data via basichttp'" />
			<send targetexpr="_ioprocessors['basichttp'].location" namelist="foo" type="basichttp" event="transitionToNext">
				<param name="bar" expr="bar" />
				<content>
<![CDATA[
This is some content you got there dude!
]]>
				</content>
			</send>
		</onentry>
		<transition event="transitionToNext" target="step1" cond="_event.data.bar == 'this is the bar data'" />
		<transition event="*" target="final">
			<log label="FAIL!" expr="dump(_event)" />
		</transition>
	</state>
	<state id="step1">
		<onentry>
			<log expr="'Entered step1'" />
			<log expr="'Sending ourself a 2s delayed event'" />
			<send delay="2s" targetexpr="_ioprocessors['basichttp'].location" type="basichttp" event="transitionToNext" />
		</onentry>
		<transition event="transitionToNext" target="step2" />
	</state>
	<state id="step2">
		<onentry>
			<log expr="'Entered step2'" />
			<log expr="'Invoking scxml interpreter'" />
		</onentry>
		<invoke type="http://www.w3.org/TR/scxml/" src="test-invoked.scxml">
			<finalize>
				<log expr="'Calling finalize on returned event'" />
			</finalize>
		</invoke>		
		<transition event="transitionToNext" target="step3" />
	</state>
	<state id="step3">
		<onentry>
			<log expr="'Entered step3'" />
			<log expr="'Sending an invalid request'" />
			<send target="http://www.sgsdfgsdfgasdf.com" type="basichttp" event="transitionToNext" />
		</onentry>
		<transition event="error.communication" target="final" />
	</state>
	<final id="final">
		<onentry>
			<log expr="'Finished!'" />
		</onentry>
	</final>
</scxml>