| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent a5bbd2a commit 74e7f2a
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -95,16 +95,14 @@ public Client(PApplet parent, String host, int port) { | |||
| 95 | 95 | // which would be called each time an event comes in | |
| 96 | 96 | try { | |
| 97 | 97 | clientEventMethod = | |
| 98 | - parent.getClass().getMethod("clientEvent", | ||
| 99 | - new Class[] { Client.class }); | ||
| 98 | + parent.getClass().getMethod("clientEvent", Client.class); | ||
| 100 | 99 | } catch (Exception e) { | |
| 101 | 100 | // no such method, or an error.. which is fine, just ignore | |
| 102 | 101 | } | |
| 103 | 102 | // do the same for disconnectEvent(Client c); | |
| 104 | 103 | try { | |
| 105 | 104 | disconnectEventMethod = | |
| 106 | - parent.getClass().getMethod("disconnectEvent", | ||
| 107 | - new Class[] { Client.class }); | ||
| 105 | + parent.getClass().getMethod("disconnectEvent", Client.class); | ||
| 108 | 106 | } catch (Exception e) { | |
| 109 | 107 | // no such method, or an error.. which is fine, just ignore | |
| 110 | 108 | } | |
@@ -138,8 +136,7 @@ public Client(PApplet parent, Socket socket) throws IOException { | |||
| 138 | 136 | // public void disconnectEvent(processing.net.Client) | |
| 139 | 137 | try { | |
| 140 | 138 | disconnectEventMethod = | |
| 141 | - parent.getClass().getMethod("disconnectEvent", | ||
| 142 | - new Class[] { Client.class }); | ||
| 139 | + parent.getClass().getMethod("disconnectEvent", Client.class); | ||
| 143 | 140 | } catch (Exception e) { | |
| 144 | 141 | // no such method, or an error.. which is fine, just ignore | |
| 145 | 142 | } | |
@@ -160,7 +157,7 @@ public Client(PApplet parent, Socket socket) throws IOException { | |||
| 160 | 157 | public void stop() { | |
| 161 | 158 | if (disconnectEventMethod != null && thread != null){ | |
| 162 | 159 | try { | |
| 163 | - disconnectEventMethod.invoke(parent, new Object[] { this }); | ||
| 160 | + disconnectEventMethod.invoke(parent, this); | ||
| 164 | 161 | } catch (Exception e) { | |
| 165 | 162 | e.printStackTrace(); | |
| 166 | 163 | disconnectEventMethod = null; | |
@@ -211,6 +208,7 @@ public void dispose() { | |||
| 211 | 208 | } | |
| 212 | 209 | ||
| 213 | 210 | ||
| 211 | + @Override | ||
| 214 | 212 | public void run() { | |
| 215 | 213 | byte[] readBuffer = new byte[2048]; // Ethernet MTU = 1500 B | |
| 216 | 214 | while (Thread.currentThread() == thread) { | |
@@ -269,7 +267,7 @@ public void run() { | |||
| 269 | 267 | // now post an event | |
| 270 | 268 | if (clientEventMethod != null) { | |
| 271 | 269 | try { | |
| 272 | - clientEventMethod.invoke(parent, new Object[] { this }); | ||
| 270 | + clientEventMethod.invoke(parent, this); | ||
| 273 | 271 | } catch (Exception e) { | |
| 274 | 272 | System.err.println("error, disabling clientEvent() for " + host); | |
| 275 | 273 | e.printStackTrace(); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments