aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/RDGE/src/core/script/sockets.js
diff options
context:
space:
mode:
authorValerio Virgillito2012-07-09 14:35:44 -0700
committerValerio Virgillito2012-07-09 14:35:44 -0700
commit84b3327bd92faafab7954b5eb64c7abe24a3fe13 (patch)
tree3f56cbed2f08c5a81ea79eaf0bcb9bd031d8a627 /js/helper-classes/RDGE/src/core/script/sockets.js
parentc0a42c56f768a873ba637f5b86d5f6a84d4a3312 (diff)
parent40c6eb2c06b34f65a74d59ef9687251952858bab (diff)
downloadninja-84b3327bd92faafab7954b5eb64c7abe24a3fe13.tar.gz
Merge branch 'normalize' of https://github.com/kriskowal/ninja-internal
Conflicts: js/components/gradientpicker.reel/gradientpicker.js js/components/tools-properties/text-properties.reel/text-properties.js js/document/views/base.js js/document/views/design.js js/helper-classes/3D/StageLine.js js/helper-classes/3D/draw-utils.js js/lib/drawing/world.js js/lib/geom/circle.js js/lib/geom/line.js js/lib/geom/rectangle.js js/lib/geom/shape-primitive.js js/lib/rdge/materials/bump-metal-material.js js/lib/rdge/materials/flag-material.js js/lib/rdge/materials/fly-material.js js/lib/rdge/materials/julia-material.js js/lib/rdge/materials/keleidoscope-material.js js/lib/rdge/materials/mandel-material.js js/lib/rdge/materials/material.js js/lib/rdge/materials/plasma-material.js js/lib/rdge/materials/pulse-material.js js/lib/rdge/materials/radial-gradient-material.js js/lib/rdge/materials/taper-material.js js/lib/rdge/materials/twist-vert-material.js js/lib/rdge/materials/water-material.js js/panels/Materials/materials-library-panel.reel/materials-library-panel.html js/panels/Materials/materials-library-panel.reel/materials-library-panel.js js/panels/Materials/materials-popup.reel/materials-popup.html js/panels/Materials/materials-popup.reel/materials-popup.js js/tools/LineTool.js Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'js/helper-classes/RDGE/src/core/script/sockets.js')
-rwxr-xr-xjs/helper-classes/RDGE/src/core/script/sockets.js362
1 files changed, 181 insertions, 181 deletions
diff --git a/js/helper-classes/RDGE/src/core/script/sockets.js b/js/helper-classes/RDGE/src/core/script/sockets.js
index 7d6192d2..2f79973c 100755
--- a/js/helper-classes/RDGE/src/core/script/sockets.js
+++ b/js/helper-classes/RDGE/src/core/script/sockets.js
@@ -1,181 +1,181 @@
1/* <copyright> 1/* <copyright>
2Copyright (c) 2012, Motorola Mobility, Inc 2Copyright (c) 2012, Motorola Mobility, Inc
3All Rights Reserved. 3All Rights Reserved.
4BSD License. 4BSD License.
5 5
6Redistribution and use in source and binary forms, with or without 6Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are met: 7modification, are permitted provided that the following conditions are met:
8 8
9 - Redistributions of source code must retain the above copyright notice, 9 - Redistributions of source code must retain the above copyright notice,
10 this list of conditions and the following disclaimer. 10 this list of conditions and the following disclaimer.
11 - Redistributions in binary form must reproduce the above copyright 11 - Redistributions in binary form must reproduce the above copyright
12 notice, this list of conditions and the following disclaimer in the 12 notice, this list of conditions and the following disclaimer in the
13 documentation and/or other materials provided with the distribution. 13 documentation and/or other materials provided with the distribution.
14 - Neither the name of Motorola Mobility nor the names of its contributors 14 - Neither the name of Motorola Mobility nor the names of its contributors
15 may be used to endorse or promote products derived from this software 15 may be used to endorse or promote products derived from this software
16 without specific prior written permission. 16 without specific prior written permission.
17 17
18THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 21ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28POSSIBILITY OF SUCH DAMAGE. 28POSSIBILITY OF SUCH DAMAGE.
29</copyright> */ 29</copyright> */
30 30
31// RDGE namespaces 31// RDGE namespaces
32var RDGE = RDGE || {}; 32var RDGE = RDGE || {};
33 33
34/* 34/*
35* Simple socket connection discovery and management 35* Simple socket connection discovery and management
36*/ 36*/
37 37
38RDGE.CreateSocket = function (url, listenList, connectedList, messageHandler, socketID, openHandler, closeHandler) { 38RDGE.CreateSocket = function (url, listenList, connectedList, messageHandler, socketID, openHandler, closeHandler) {
39 var ws = new WebSocket(url); 39 var ws = new WebSocket(url);
40 40
41 ws.listenIndex = socketID; 41 ws.listenIndex = socketID;
42 42
43 ws.onmessage = messageHandler; 43 ws.onmessage = messageHandler;
44 44
45 ws.connectedList = connectedList; 45 ws.connectedList = connectedList;
46 ws.listenList = listenList; 46 ws.listenList = listenList;
47 47
48 // make up a flag 48 // make up a flag
49 ws.rdge_isConnected = false; 49 ws.rdge_isConnected = false;
50 ws.rdge_tryDisconnect = false; 50 ws.rdge_tryDisconnect = false;
51 51
52 if (openHandler) { 52 if (openHandler) {
53 ws.addEventListener("open", openHandler); 53 ws.addEventListener("open", openHandler);
54 } 54 }
55 if (closeHandler) { 55 if (closeHandler) {
56 ws.addEventListener("close", closeHandler); 56 ws.addEventListener("close", closeHandler);
57 ws.addEventListener("error", closeHandler); 57 ws.addEventListener("error", closeHandler);
58 } 58 }
59 59
60 ws.onopen = function (evt) { 60 ws.onopen = function (evt) {
61 var websocket = evt.srcElement; 61 var websocket = evt.srcElement;
62 document.getElementById("socketConnection").innerHTML += "connected: " + websocket.URL + "</br>"; 62 document.getElementById("socketConnection").innerHTML += "connected: " + websocket.URL + "</br>";
63 63
64 websocket.rdge_isConnected = true; 64 websocket.rdge_isConnected = true;
65 65
66 websocket.connectedList.push(ws); 66 websocket.connectedList.push(ws);
67 67
68 // save the connected array index of this item 68 // save the connected array index of this item
69 ws.connectedIndex = websocket.connectedList.length - 1; 69 ws.connectedIndex = websocket.connectedList.length - 1;
70 }; 70 };
71 71
72 ws.onerror = function (event) { 72 ws.onerror = function (event) {
73 window.console.log("error: " + event); 73 window.console.log("error: " + event);
74 } 74 }
75 75
76 ws.onclose = function (evt) { 76 ws.onclose = function (evt) {
77 var websocket = evt.srcElement; 77 var websocket = evt.srcElement;
78 78
79 websocket.rdge_isConnected = false; 79 websocket.rdge_isConnected = false;
80 80
81 // send disconnect message 81 // send disconnect message
82 websocket.send("type=srv\nmsg=2\n"); 82 websocket.send("type=srv\nmsg=2\n");
83 83
84 // remove from connected sockets 84 // remove from connected sockets
85 websocket.connectedList[websocket.connectedIndex, 1]; 85 websocket.connectedList[websocket.connectedIndex, 1];
86 86
87 // re-open port for listening 87 // re-open port for listening
88 //websocket.listenList[websocket.listenIndex] = new WebSocket(websocket.URL.toString()); 88 //websocket.listenList[websocket.listenIndex] = new WebSocket(websocket.URL.toString());
89 89
90 //document.getElementById("socketConnection").innerHTML += "disconnected: " + websocket.URL +"</br>"; 90 //document.getElementById("socketConnection").innerHTML += "disconnected: " + websocket.URL +"</br>";
91 }; 91 };
92 92
93 return ws; 93 return ws;
94}; 94};
95 95
96// The DCHP range on Whitney 10.0.0.1 - 10.0.0.254 96// The DCHP range on Whitney 10.0.0.1 - 10.0.0.254
97 97
98// add the connection Pool's to this list for auto polling 98// add the connection Pool's to this list for auto polling
99RDGE.ConnPoll = function() { 99RDGE.ConnPoll = function() {
100 var len = RDGE.globals.poolList.length; 100 var len = RDGE.globals.poolList.length;
101 for (var i = 0; i < len; ++i) { 101 for (var i = 0; i < len; ++i) {
102 RDGE.globals.poolList[i].Poll(); 102 RDGE.globals.poolList[i].Poll();
103 } 103 }
104}; 104};
105 105
106/* 106/*
107* manages a connection 107* manages a connection
108* @param base: base url minus the last octet (ie "ws://192.168.1.") 108* @param base: base url minus the last octet (ie "ws://192.168.1.")
109* @param startAddr: the last octect of the beginning address range (ie 10.0.0.x where x is the value passed in for startAddr) 109* @param startAddr: the last octect of the beginning address range (ie 10.0.0.x where x is the value passed in for startAddr)
110* @param endAddr: the last octect of the end address range (ie 10.0.0.x where x is the value passed in for endAddr) 110* @param endAddr: the last octect of the end address range (ie 10.0.0.x where x is the value passed in for endAddr)
111* @param messageHandlerFunc: handle to onMessage function 111* @param messageHandlerFunc: handle to onMessage function
112*/ 112*/
113RDGE.ConnectionPool = funciton(base, startAddr, endAddr, messageHandlerFunc) 113RDGE.ConnectionPool = funciton(base, startAddr, endAddr, messageHandlerFunc)
114{ 114{
115 this.start = startAddr; 115 this.start = startAddr;
116 this.end = endAddr; 116 this.end = endAddr;
117 this.port = 38951; 117 this.port = 38951;
118 this.messageHandler = messageHandlerFunc; 118 this.messageHandler = messageHandlerFunc;
119 119
120 this.listenSockets = []; 120 this.listenSockets = [];
121 this.connectedSockets = []; 121 this.connectedSockets = [];
122 122