15 object_add: function(data) { }, |
17 object_add: function(data) { }, |
16 object_update: function(data) { }, |
18 object_update: function(data) { }, |
17 object_remove: function(data) { }, |
19 object_remove: function(data) { }, |
18 cursor_add: function(data) { }, |
20 cursor_add: function(data) { }, |
19 cursor_update: function(data) { }, |
21 cursor_update: function(data) { }, |
20 cursor_remove: function(data) { } |
22 cursor_remove: function(data) { }, |
|
23 string_add: function(data) { }, |
|
24 string_update: function(data) { }, |
|
25 string_remove: function(data) { } |
21 } |
26 } |
22 |
27 |
23 // Instance variables |
28 // Instance variables |
24 |
29 |
25 this.objects = []; |
30 this.objects = []; |
26 this.cursors = []; |
31 this.cursors = []; |
|
32 this.strings = []; |
27 |
33 |
28 this._data = {}; |
34 this._data = {}; |
29 |
35 |
30 this._default_listener = new this.Listener(); |
36 this._default_listener = new this.Listener(); |
31 this._listeners = [this._default_listener]; |
37 this._listeners = [this._default_listener]; |
69 var listener = this._listeners[i]; |
75 var listener = this._listeners[i]; |
70 listener[method](data); |
76 listener[method](data); |
71 } |
77 } |
72 }, |
78 }, |
73 |
79 |
74 callback: function(type, sid, fid, x, y, z, angle) { |
80 cursorCallback: function(type, sid, fid, x, y, z, angle) { |
|
81 if(type >= 6) |
|
82 return; |
|
83 |
75 var data; |
84 var data; |
76 |
85 |
77 if ((type != 0) && (type != 3)) { |
86 if ((type != 0) && (type != 3)) { |
78 data = this._data[sid]; |
87 data = this._data[sid]; |
79 } |
88 } |
131 |
140 |
132 if ((type == 2) || (type == 5)) { |
141 if ((type == 2) || (type == 5)) { |
133 delete this._data[sid]; |
142 delete this._data[sid]; |
134 } |
143 } |
135 }, |
144 }, |
|
145 |
|
146 stringCallback: function(type, sid, code) { |
|
147 if(type < 6) |
|
148 return; |
|
149 |
|
150 var data; |
|
151 |
|
152 if ((type != 6)) { |
|
153 data = this._data[sid]; |
|
154 } |
|
155 else { |
|
156 data = { |
|
157 sid: sid, |
|
158 code: code |
|
159 } |
|
160 this._data[sid] = data; |
|
161 } |
|
162 |
|
163 //data.code = code; |
|
164 |
|
165 switch (type) { |
|
166 case 6: |
|
167 if(this.strings != null && this.strings.length <= 0) |
|
168 { |
|
169 this.strings.push(data); |
|
170 this._invoke('string_add', data); |
|
171 test++; |
|
172 //alert(test); |
|
173 } |
|
174 break; |
|
175 |
|
176 case 7: |
|
177 this._invoke('string_update', data); |
|
178 break; |
|
179 |
|
180 case 8: |
|
181 //var str = ""; |
|
182 //for(var j = 0 ; j < this.strings.length ; j++) |
|
183 //str += "(" + this.strings[i].sid + ")" + this.strings[i].code + " "; |
|
184 //alert(str); |
|
185 //this.strings.splice(this.strings.indexOf(data), 1); |
|
186 this.strings.length = 0; |
|
187 this._invoke('string_remove', data); |
|
188 test--; |
|
189 alert(test); |
|
190 break; |
|
191 |
|
192 default: |
|
193 break; |
|
194 } |
|
195 |
|
196 if ((type == 8)) { |
|
197 delete this._data[sid]; |
|
198 } |
|
199 }, |
136 |
200 |
137 // Convenient callbacks set |
201 // Convenient callbacks set |
138 |
202 |
139 object_add: function(f) { this._default_listener.object_add = f; }, |
203 object_add: function(f) { this._default_listener.object_add = f; }, |
140 object_update: function(f) { this._default_listener.object_update = f; }, |
204 object_update: function(f) { this._default_listener.object_update = f; }, |
141 object_remove: function(f) { this._default_listener.object_remove = f; }, |
205 object_remove: function(f) { this._default_listener.object_remove = f; }, |
142 cursor_add: function(f) { this._default_listener.cursor_add = f; }, |
206 cursor_add: function(f) { this._default_listener.cursor_add = f; }, |
143 cursor_update: function(f) { this._default_listener.cursor_update = f; }, |
207 cursor_update: function(f) { this._default_listener.cursor_update = f; }, |
144 cursor_remove: function(f) { this._default_listener.cursor_remove = f; } |
208 cursor_remove: function(f) { this._default_listener.cursor_remove = f; }, |
|
209 string_add: function(f) { this._default_listener.string_add = f; }, |
|
210 string_update: function(f) { this._default_listener.string_update = f; }, |
|
211 string_remove: function(f) { this._default_listener.string_remove = f; } |
145 |
212 |
146 }; |
213 }; |
147 this.tuio = new TUIO(); |
214 this.tuio = new TUIO(); |
148 })(); |
215 })(); |
149 |
216 |