diff options
Diffstat (limited to 'point/binding/network.js')
-rw-r--r-- | point/binding/network.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/point/binding/network.js b/point/binding/network.js new file mode 100644 index 0000000..11cf58a --- /dev/null +++ b/point/binding/network.js | |||
@@ -0,0 +1,40 @@ | |||
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 | |||
19 | define(["control/control", "libs/webcastor/webcastor"], function (control, webcastor) { | ||
20 | |||
21 | var network = { | ||
22 | |||
23 | init: function (settings) { | ||
24 | webcastor.init(settings, function (socket) { | ||
25 | network.bindEvents(); | ||
26 | }); | ||
27 | }, | ||
28 | |||
29 | /* network -> local */ | ||
30 | bindEvents: function () { | ||
31 | webcastor.on("message", function (message) { | ||
32 | var event = JSON.parse(message); | ||
33 | control.dispatchEvent(event.event, event.eventDetail, false); | ||
34 | }); | ||
35 | }, | ||
36 | }; | ||
37 | |||
38 | return network; | ||
39 | |||
40 | }); | ||