Class Cast Exception on obtainMessage from Pool

  ... the Multiplayer Extension for AndEngine.

Class Cast Exception on obtainMessage from Pool

Postby Paschalis » Sun Apr 22, 2012 9:02 am

When i obtain message from message pool with the below code:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.                         ServerSendScore serverSendScore = (ServerSendScore) mMessagePool
  2.                                         .obtainMessage(FLAG_MESSAGE_SERVER_SEND_SCORE);
  3.                         // new ServerSendScore(mCode);
  4.  
  5.                         // Send it to client
  6.                         try {
  7.                                 mSocketServer.sendBroadcastServerMessage(serverSendScore);
  8.                         } catch (IOException e) {
  9.                                 // TODO Auto-generated catch block
  10.                                 e.printStackTrace();
  11.                         }
  12.  
  13.                         mMessagePool.recycleMessage(serverSendScore);
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


I get the below exception:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. 04-22 10:00:02.142: E/AndroidRuntime(28894): Caused by: java.lang.ClassCastException: cy.ac.ucy.AndroidTeam.Connection.Client.ClientSendScore
  2. 04-22 10:00:02.142: E/AndroidRuntime(28894):    at cy.ac.ucy.AndroidTeam.Game.MultiplayerGame$ServerInformClientAboutScore.doInBackground(MultiplayerGame.java:247)
  3. 04-22 10:00:02.142: E/AndroidRuntime(28894):    at android.os.AsyncTask$2.call(AsyncTask.java:185)
  4. 04-22 10:00:02.142: E/AndroidRuntime(28894):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
  5. 04-22 10:00:02.142: E/AndroidRuntime(28894):    ... 4 more
  6.  
Parsed in 0.033 seconds, using GeSHi 1.0.8.4


Whats the problem with that casting??

Also my game uses Box2D, and without MessagePools, the moving sprite, freezes..
Paschalis
 
Posts: 6
Joined: Thu Mar 22, 2012 4:34 am

Return to Multiplayer

Who is online

Users browsing this forum: No registered users and 1 guest