aboutsummaryrefslogtreecommitdiff
path: root/point/control/network.js
diff options
context:
space:
mode:
authorPacien TRAN-GIRARD2014-08-10 17:28:37 +0200
committerPacien TRAN-GIRARD2014-08-10 17:28:37 +0200
commite7bf5952d0729b37e677168b6e8fbd1ce58ed1a2 (patch)
tree189988e3e272b806262d1df6b87f1da089ef4af8 /point/control/network.js
parenta32e898c8d7ad3774f5654e88bb24d5c26482137 (diff)
downloadwhatsthepoint-master.tar.gz
First versionHEADmaster
Diffstat (limited to 'point/control/network.js')
-rw-r--r--point/control/network.js58
1 files changed, 58 insertions, 0 deletions
diff --git a/point/control/network.js b/point/control/network.js
new file mode 100644
index 0000000..e782257
--- /dev/null
+++ b/point/control/network.js
@@ -0,0 +1,58 @@
1/*
2 * This file is part of "What's The Point" <https://github.com/Pacien/WhatsThePoint>
3 * Copyright (C) 2014 Pacien TRAN-GIRARD
4 *
5 * "What's The Point" is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Affero General Public License as
7 * published by the Free Software Foundation, either version 3 of the
8 * License, or (at your option) any later version.
9 *
10 * "What's The Point" is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Affero General Public License for more details.
14 *
15 * You should have received a copy of the GNU Affero General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19define([ "control/control", "libs/webcastor/webcastor", "control/slide" ], function (control, webcastor, slide) {
20
21 var network = {
22
23 init: function (settings) {
24 webcastor.init(settings, function () {
25 network.bindEvents();
26 });
27 },
28
29 send: function (event, eventDetail) {
30 var message = JSON.stringify({
31 "event": event,
32 "eventDetail": eventDetail,
33 });
34 webcastor.send(message);
35 },
36
37 bindEvent: function (event) {
38 control.bindEvent(event, function (eventDetail) {
39 if (!eventDetail.forward) {
40 return false;
41 }
42 network.send(event, eventDetail.detail);
43 });
44 },
45
46 /* local -> network */
47 bindEvents: function () {
48 var events = [ control.EVENT.SLIDE, control.EVENT.TRIGGER ];
49 for (var i = 0; i < events.length; i++) {
50 this.bindEvent(events[i]);
51 }
52 },
53
54 };
55
56 return network;
57
58});