blob: 2cad7ba219563c81cf3a7ccb73d319b09acc88f8 (
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
<scxml name="miles" datamodel="ecmascript">
<script src="http://uscxml.tk.informatik.tu-darmstadt.de/scripts/dump.js" />
<state id="main">
<invoke type="miles" id="miles">
<finalize>
<!-- <log label="out" expr="_event.name" /> -->
<script>//dump(_event);</script>
<if cond="_event.data.origin">
<!-- <log label="Reply-length" expr="_event.data.base64.length" /> -->
<if cond="_event.name === 'thumbnail.reply'">
<respond status="200" to="_event.data.origin">
<header name="Cache-Control" value="no-cache" /> <!-- force IE to actually reload -->
<header name="Access-Control-Allow-Origin" value="*" />
<header name="Content-Type" value="text/plain" />
<header name="Access-Control-Allow-Origin" value="*" />
<content expr="_event.data.image.base64()" />
</respond>
<else />
<respond status="200" to="_event.data.origin">
<header name="Cache-Control" value="no-cache" /> <!-- force IE to actually reload -->
<header name="Access-Control-Allow-Origin" value="*" />
<!-- respond element will add content-type header -->
<header name="Access-Control-Allow-Origin" value="*" />
<content expr="_event.data" />
</respond>
</if>
<else />
<log label="Error" expr="'Event returned from invoker did not specify its origin for a reply'" />
</if>
</finalize>
</invoke>
<state id="idle">
<!-- XHR CORS preflight respond -->
<transition event="http.options" target="idle">
<respond status="200" to="_event.origin">
<header name="Access-Control-Allow-Origin" value="*" /> <!-- request origins we allow -->
<header name="Access-Control-Allow-Methods" value="POST, GET, OPTIONS" /> <!-- http methods we allow -->
<header name="Access-Control-Allow-Headers"
value="X-Requested-With, X-Content-Encoding, Content-Type" /> <!-- headers we allow -->
</respond>
</transition>
<transition event="http.get" target="idle">
<!-- <log label="in" expr="_event.data.path" /> -->
<script>//dump(_event);</script>
<if cond="false">
<!-- START ############### -->
<elseif cond="_event.data.pathComponent[1] === 'start'" />
<send target="#_miles" event="start">
<param name="origin" expr="_event.origin" />
<param name="reflector" expr="_event.data.query.reflector" />
<param name="userId" expr="_event.data.query.userid" />
<param name="session" expr="_event.data.query.session" />
</send>
<!-- STOP ############### -->
<elseif cond="_event.data.pathComponent[1] === 'stop'" />
<send target="#_miles" event="stop">
<param name="origin" expr="_event.origin" />
<param name="reflector" expr="_event.data.query.reflector" />
<param name="userId" expr="_event.data.query.userid" />
<param name="session" expr="_event.data.query.session" />
</send>
<!-- PARTICIPANTS ############### -->
<elseif cond="_event.data.pathComponent[1] === 'participants'" />
<send target="#_miles" event="participants">
<param name="origin" expr="_event.origin" />
</send>
<!-- THUMBNAIL ############### -->
<elseif cond="_event.data.pathComponent[1] === 'thumbnail'" />
<send target="#_miles" event="thumbnail">
<param name="origin" expr="_event.origin" />
<param name="userId" expr="_event.data.query.userid" />
</send>
<!-- VIDEO ON ############### -->
<elseif cond="_event.data.pathComponent[1] === 'videoon'" />
<send target="#_miles" event="videoon">
<param name="origin" expr="_event.origin" />
<param name="userid" expr="_event.data.query.userid" />
</send>
<!-- VIDEO OFF ############### -->
<elseif cond="_event.data.pathComponent[1] === 'videooff'" />
<send target="#_miles" event="videooff">
<param name="origin" expr="_event.origin" />
<param name="userid" expr="_event.data.query.userid" />
</send>
<!-- AUDIO ON ############### -->
<elseif cond="_event.data.pathComponent[1] === 'audioon'" />
<send target="#_miles" event="audioon">
<param name="origin" expr="_event.origin" />
<param name="userid" expr="_event.data.query.userid" />
</send>
<!-- AUDIO OFF ############### -->
<elseif cond="_event.data.pathComponent[1] === 'videooff'" />
<send target="#_miles" event="audiooff">
<param name="origin" expr="_event.origin" />
<param name="userid" expr="_event.data.query.userid" />
</send>
<!-- SEND VIDEO ############### -->
<elseif cond="_event.data.pathComponent[1] === 'sendvideo'" />
<send target="#_miles" event="sendvideo">
<param name="origin" expr="_event.origin" />
<param name="width" expr="_event.data.query.width" />
<param name="height" expr="_event.data.query.height" />
<param name="framerate" expr="_event.data.query.framerate" />
<param name="compression" expr="_event.data.query.compression" />
</send>
<!-- SEND VIDEO OFF ############### -->
<elseif cond="_event.data.pathComponent[1] === 'sendvideooff'" />
<send target="#_miles" event="sendvideooff">
<param name="origin" expr="_event.origin" />
</send>
<!-- SEND AUDIO ############### -->
<elseif cond="_event.data.pathComponent[1] === 'sendaudio'" />
<send target="#_miles" event="sendaudio">
<param name="origin" expr="_event.origin" />
<param name="encoding" expr="_event.data.query.encoding" />
</send>
<!-- SEND AUDIO OFF ############### -->
<elseif cond="_event.data.pathComponent[1] === 'sendaudiooff'" />
<send target="#_miles" event="sendaudiooff">
<param name="origin" expr="_event.origin" />
</send>
<!-- GET TEXT ############### -->
<elseif cond="_event.data.pathComponent[1] === 'gettext'" />
<send target="#_miles" event="gettext">
<param name="origin" expr="_event.origin" />
</send>
<else />
<respond status="404" to="_event.origin" />
</if>
</transition>
<transition event="http.post" target="idle">
<!-- <log label="in" expr="_event.data.path" /> -->
<script>//dump(_event);</script>
<if cond="false">
<!-- POST TEXT ############### -->
<elseif cond="_event.data.pathComponent[1] === 'text'" />
<send target="#_miles" event="posttext">
<param name="origin" expr="_event.origin" />
<param name="userid" expr="_event.data.content.userid" />
<param name="message" expr="_event.data.content.message" />
</send>
<else />
<respond status="404" to="_event.origin" />
</if>
</transition>
</state>
</state>
</scxml>
|