aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/RDGE/src/core/script/sockets.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/helper-classes/RDGE/src/core/script/sockets.js')
-rwxr-xr-xjs/helper-classes/RDGE/src/core/script/sockets.js130
1 files changed, 65 insertions, 65 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..e5334280 100755
--- a/js/helper-classes/RDGE/src/core/script/sockets.js
+++ b/js/helper-classes/RDGE/src/core/script/sockets.js
@@ -112,70 +112,70 @@ RDGE.ConnPoll = 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
123 this.openHandler = null; 123 this.openHandler = null;
124 this.closeHandler = null; 124 this.closeHandler = null;
125 125
126 this.interval = null; 126 this.interval = null;
127 127
128 this.Init = function (openHandler, closeHandler) { 128 this.Init = function (openHandler, closeHandler) {
129 // empty out lists 129 // empty out lists
130 this.listenSockets = []; 130 this.listenSockets = [];
131 this.connectedSockets = []; 131 this.connectedSockets = [];
132 132
133 this.openHandler = openHandler; 133 this.openHandler = openHandler;
134 this.closeHandler = closeHandler; 134 this.closeHandler = closeHandler;
135 135
136 var len = this.end - this.start; 136 var len = this.end - this.start;
137 for (var i = 0; i < len; ++i) { 137 for (var i = 0; i < len; ++i) {
138 var url = base + (this.start + i) + ":" + this.port + "/resourcePath"; 138 var url = base + (this.start + i) + ":" + this.port + "/resourcePath";
139 var ws = CreateSocket(url, this.listenSockets, this.connectedSockets, this.messageHandler, i, this.openHandler, this.closeHandler); 139 var ws = CreateSocket(url, this.listenSockets, this.connectedSockets, this.messageHandler, i, this.openHandler, this.closeHandler);
140 140
141 this.listenSockets.push(ws); 141 this.listenSockets.push(ws);
142 } 142 }
143 143
144 this.interval = setInterval(ConnPoll, 200); 144 this.interval = setInterval(ConnPoll, 200);
145 }; 145 };
146 146
147 this.Shutdown = function () { 147 this.Shutdown = function () {
148 if (this.interval != null) { 148 if (this.interval != null) {
149 clearInterval(this.interval); 149 clearInterval(this.interval);
150 this.interval = null; 150 this.interval = null;
151 } 151 }
152 var len = this.connectedSockets.length; 152 var len = this.connectedSockets.length;
153 for (var i = 0; i < len; ++i) { 153 for (var i = 0; i < len; ++i) {
154 // send disconnect message 154 // send disconnect message
155 this.connectedSockets[i].send("type=srv\nmsg=2\n"); ; 155 this.connectedSockets[i].send("type=srv\nmsg=2\n"); ;
156 } 156 }
157 }; 157 };
158 158
159 this.Close = function (socket) { 159 this.Close = function (socket) {
160 socket.rdge_tryDisconnect = true; 160 socket.rdge_tryDisconnect = true;
161 }; 161 };
162 162
163 this.Poll = function () { 163 this.Poll = function () {
164 var len = this.end - this.start; 164 var len = this.end - this.start;
165 for (var i = 0; i < len; ++i) { 165 for (var i = 0; i < len; ++i) {
166 // re init the sockets to simulate broadcast 166 // re init the sockets to simulate broadcast
167 if (this.listenSockets[i].readyState == 3/*CLOSING*/ || this.listenSockets[i].readyState == 2/*CLOSING*/ || this.listenSockets[i].rdge_tryDisconnect == true) { 167 if (this.listenSockets[i].readyState == 3/*CLOSING*/ || this.listenSockets[i].readyState == 2/*CLOSING*/ || this.listenSockets[i].rdge_tryDisconnect == true) {
168 if (this.listenSockets[i].rdge_tryDisconnect) { 168 if (this.listenSockets[i].rdge_tryDisconnect) {
169 document.getElementById("socketConnection").innerHTML += "graceful discon: " + this.listenSockets[i].URL + "</br>"; 169 document.getElementById("socketConnection").innerHTML += "graceful discon: " + this.listenSockets[i].URL + "</br>";
170 } 170 }
171 171
172 this.listenSockets[i].rdge_tryDisconnect = false; 172 this.listenSockets[i].rdge_tryDisconnect = false;
173 173
174 var url = base + (this.start + i) + ":" + this.port + "/resourcePath"; 174 var url = base + (this.start + i) + ":" + this.port + "/resourcePath";
175 this.listenSockets[i].close(); 175 this.listenSockets[i].close();
176 this.listenSockets[i] = CreateSocket(url, this.listenSockets, this.connectedSockets, this.messageHandler, i, this.openHandler, this.closeHandler); 176 this.listenSockets[i] = CreateSocket(url, this.listenSockets, this.connectedSockets, this.messageHandler, i, this.openHandler, this.closeHandler);
177 } 177 }
178 } 178 }
179 }; 179 };
180}; 180};
181 181