File tree Expand file tree Collapse file tree
java/libraries/net/src/processing/net Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2424*/
2525
2626package processing .net ;
27+
2728import processing .core .*;
2829
2930import java .io .*;
3031import java .lang .reflect .*;
3132import java .net .*;
3233
34+
3335/**
3436 * ( begin auto-generated from Server.xml )
3537 *
@@ -128,6 +130,21 @@ protected void removeIndex(int index) {
128130 }
129131
130132
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+
131148 protected void addClient (Client client ) {
132149 if (clientCount == clients .length ) {
133150 clients = (Client []) PApplet .expand (clients );
@@ -215,9 +232,7 @@ public void dispose() {
215232 thread = null ;
216233
217234 if (clients != null ) {
218- while (clientCount >0 ){
219- disconnect (clients [0 ]);
220- }
235+ disconnectAll ();
221236 clientCount = 0 ;
222237 clients = null ;
223238 }
@@ -310,15 +325,4 @@ public void write(String data) {
310325 }
311326 }
312327 }
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- // }
324328}
You can’t perform that action at this time.
0 commit comments