@@ -95,16 +95,14 @@ public Client(PApplet parent, String host, int port) {
9595 // which would be called each time an event comes in
9696 try {
9797 clientEventMethod =
98- parent .getClass ().getMethod ("clientEvent" ,
99- new Class [] { Client .class });
98+ parent .getClass ().getMethod ("clientEvent" , Client .class );
10099 } catch (Exception e ) {
101100 // no such method, or an error.. which is fine, just ignore
102101 }
103102 // do the same for disconnectEvent(Client c);
104103 try {
105104 disconnectEventMethod =
106- parent .getClass ().getMethod ("disconnectEvent" ,
107- new Class [] { Client .class });
105+ parent .getClass ().getMethod ("disconnectEvent" , Client .class );
108106 } catch (Exception e ) {
109107 // no such method, or an error.. which is fine, just ignore
110108 }
@@ -138,8 +136,7 @@ public Client(PApplet parent, Socket socket) throws IOException {
138136 // public void disconnectEvent(processing.net.Client)
139137 try {
140138 disconnectEventMethod =
141- parent .getClass ().getMethod ("disconnectEvent" ,
142- new Class [] { Client .class });
139+ parent .getClass ().getMethod ("disconnectEvent" , Client .class );
143140 } catch (Exception e ) {
144141 // no such method, or an error.. which is fine, just ignore
145142 }
@@ -160,7 +157,7 @@ public Client(PApplet parent, Socket socket) throws IOException {
160157 public void stop () {
161158 if (disconnectEventMethod != null && thread != null ){
162159 try {
163- disconnectEventMethod .invoke (parent , new Object [] { this } );
160+ disconnectEventMethod .invoke (parent , this );
164161 } catch (Exception e ) {
165162 e .printStackTrace ();
166163 disconnectEventMethod = null ;
@@ -211,6 +208,7 @@ public void dispose() {
211208 }
212209
213210
211+ @ Override
214212 public void run () {
215213 byte [] readBuffer = new byte [2048 ]; // Ethernet MTU = 1500 B
216214 while (Thread .currentThread () == thread ) {
@@ -269,7 +267,7 @@ public void run() {
269267 // now post an event
270268 if (clientEventMethod != null ) {
271269 try {
272- clientEventMethod .invoke (parent , new Object [] { this } );
270+ clientEventMethod .invoke (parent , this );
273271 } catch (Exception e ) {
274272 System .err .println ("error, disabling clientEvent() for " + host );
275273 e .printStackTrace ();
0 commit comments