PongExampleActivity

  ... the Multiplayer Extension for AndEngine.

PongExampleActivity

Postby greatergoodguy » Thu Jun 21, 2012 3:30 am

Hey everyone. Like you guys, I am trying to learn network programming by looking at the Pong Example. I pulled the latest code, both the multiplayer extension and the andengine.

However, I'm getting many errors and instability in the Pong Example. There are two bugs that I found.


When you exit the PongGameActivity, the onDestroy method is executed. This causes a runtime exception. This may be minor but I'd like to handle ending the server correctly. As you can see, the failure point is sandwiched between my comments in the code.
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.         @Override
  2.         protected void onDestroy() {
  3.                 if(this.mServer != null) {
  4.                         try {
  5.                                 this.mServer.sendBroadcastServerMessage(new ConnectionCloseServerMessage());
  6.                         } catch (final IOException e) {
  7.                                 Debug.e(e);
  8.                         }
  9.                         this.mServer.terminate();
  10.                 }
  11.  
  12.                 // BUG OCCURS HERE
  13.                 if(this.mServerConnector != null) {
  14.                         this.mServerConnector.terminate();
  15.                 }
  16.                 // BUG IS ABOVE
  17.  
  18.                 super.onDestroy();
  19.         }
Parsed in 0.033 seconds, using GeSHi 1.0.8.4


And here is the error message.

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. 06-20 20:26:28.970: E/AndEngine(20161): java.net.SocketException: Socket closed
  2.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4





The next error is much more alarming since it happens during game play and is causing instability. The bug is this. After I connect both devices (Galaxy tab 10.1 is the server, Samsung smartphone is the client), the game will just crash and I will get this error.

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. 06-20 20:23:56.646: E/AndEngine(16311): java.net.SocketException: Bad file number
  2.  
Parsed in 0.034 seconds, using GeSHi 1.0.8.4


I discovered AndEngine in April and have been loving it ever since. However, I really want to get Multiplayer working. For those that are more veteran to the engine, do you have any tips? Or is there an older version of AndEngine or the Multiplayer Extension that works with high stability?
greatergoodguy
 
Posts: 8
Joined: Sun Apr 22, 2012 6:36 am

Return to Multiplayer

Who is online

Users browsing this forum: No registered users and 1 guest