| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -24,12 +24,14 @@ | |||
| 24 | 24 | */ | |
| 25 | 25 | ||
| 26 | 26 | package processing.net; | |
| 27 | + | ||
| 27 | 28 | import processing.core.*; | |
| 28 | 29 | ||
| 29 | 30 | import java.io.*; | |
| 30 | 31 | import java.lang.reflect.*; | |
| 31 | 32 | import java.net.*; | |
| 32 | 33 | ||
| 34 | + | ||
| 33 | 35 | /** | |
| 34 | 36 | * ( begin auto-generated from Server.xml ) | |
| 35 | 37 | * | |
@@ -128,6 +130,21 @@ protected void removeIndex(int index) { | |||
| 128 | 130 | } | |
| 129 | 131 | ||
| 130 | 132 | ||
| 133 | + protected void disconnectAll() { | ||
| 134 | + synchronized (clients) { | ||
| 135 | + for (int i = 0; i < clientCount; i++) { | ||
| 136 | + try { | ||
| 137 | + clients[i].stop(); | ||
| 138 | + } catch (Exception e) { | ||
| 139 | + // ignore | ||
| 140 | + } | ||
| 141 | + clients[i] = null; | ||
| 142 | + } | ||
| 143 | + clientCount = 0; | ||
| 144 | + } | ||
| 145 | + } | ||
| 146 | + | ||
| 147 | + | ||
| 131 | 148 | protected void addClient(Client client) { | |
| 132 | 149 | if (clientCount == clients.length) { | |
| 133 | 150 | clients = (Client[]) PApplet.expand(clients); | |
@@ -215,9 +232,7 @@ public void dispose() { | |||
| 215 | 232 | thread = null; | |
| 216 | 233 | ||
| 217 | 234 | if (clients != null) { | |
| 218 | - while(clientCount>0){ | ||
| 219 | - disconnect(clients[0]); | ||
| 220 | - } | ||
| 235 | + disconnectAll(); | ||
| 221 | 236 | clientCount = 0; | |
| 222 | 237 | clients = null; | |
| 223 | 238 | } | |
@@ -310,15 +325,4 @@ public void write(String data) { | |||
| 310 | 325 | } | |
| 311 | 326 | } | |
| 312 | 327 | } | |
| 313 | - | ||
| 314 | - | ||
| 315 | - /** | ||
| 316 | - * General error reporting, all corralled here just in case | ||
| 317 | - * I think of something slightly more intelligent to do. | ||
| 318 | - */ | ||
| 319 | - // public void errorMessage(String where, Exception e) { | ||
| 320 | - // parent.die("Error inside Server." + where + "()", e); | ||
| 321 | - // //System.err.println("Error inside Server." + where + "()"); | ||
| 322 | - // //e.printStackTrace(System.err); | ||
| 323 | - // } | ||
| 324 | 328 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments