| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -151,7 +151,7 @@ public Client(PApplet parent, Socket socket) throws IOException { | |||
| 151 | 151 | * @usage application | |
| 152 | 152 | */ | |
| 153 | 153 | public void stop() { | |
| 154 | - if (disconnectEventMethod != null) { | ||
| 154 | + if (disconnectEventMethod != null && thread != null){ | ||
| 155 | 155 | try { | |
| 156 | 156 | disconnectEventMethod.invoke(parent, new Object[] { this }); | |
| 157 | 157 | } catch (Exception e) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -109,12 +109,7 @@ public Server(PApplet parent, int port) { | |||
| 109 | 109 | * @param client the client to disconnect | |
| 110 | 110 | */ | |
| 111 | 111 | public void disconnect(Client client) { | |
| 112 | - //Calling client.stop() here would cause duplicate | ||
| 113 | - //calls to disconnectEvent in the containing sketch, | ||
| 114 | - //once for the stop() and once for the terminated connection. | ||
| 115 | - //Instead just dispose of the client and let the terminated | ||
| 116 | - //connection generate the disconnectEvent message; | ||
| 117 | - client.dispose(); | ||
| 112 | + client.stop(); | ||
| 118 | 113 | int index = clientIndex(client); | |
| 119 | 114 | if (index != -1) { | |
| 120 | 115 | removeIndex(index); | |
@@ -220,8 +215,8 @@ public void dispose() { | |||
| 220 | 215 | thread = null; | |
| 221 | 216 | ||
| 222 | 217 | if (clients != null) { | |
| 223 | - for (int i = 0; i < clientCount; i++) { | ||
| 224 | - disconnect(clients[i]); | ||
| 218 | + while(clientCount>0){ | ||
| 219 | + disconnect(clients[0]); | ||
| 225 | 220 | } | |
| 226 | 221 | clientCount = 0; | |
| 227 | 222 | clients = null; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments