Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (406)
games submitted by our members
Games in WIP (290)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Game Development / Networking & Multiplayer / [Kryonet] Client does not receive packet. on: 2013-01-28 18:10:55
First of all hello to all of you. This is my first post here hehe ^^.

So I decided to make a simple 2d mmorpg just for the lulz. Don't tell me it's hard. Don't tell me noone will play it. I am making it for myself and the fun of it.

Now comes the problem. I am using Slick2d for the client and I have a W-key pressed event which sends the server a request to move.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
   @Override
   public void update(GameContainer gc, int delta) throws SlickException {
      Input input = gc.getInput();
      _delta = delta;

      if (input.isKeyDown(Input.KEY_W)) {
         // cell.moveW(delta);
        i++;
         if (i == 10 && !waitMoveResponse) {            
            new MoveRequestHandler(client, cell.getX(), cell.getY());
            waitMoveResponse = true;
            i = 0;
         }
      }
   }


1  
2  
3  
4  
5  
6  
   public MoveRequestHandler(Client client, float x, float y) {
      Move4Request mreq = new Move4Request();
      mreq.x = x;
      mreq.y = y;
      client.sendTCP(mreq);
   }


Now when the server received the MoveRequest packet it does a few checks and sends back an answer.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
         public void received(Connection c, Object o) {

            if (o instanceof Login0Request) {
               new LoginRequestHandler(c, o);
            }
            if (o instanceof Message2) {
               new MessageHandler(c, o);
            }
            if (o instanceof Login3Register) {
               new LoginRegisterHandler(c, o);
            }
            if (o instanceof Move4Request) {
               new MoveRequestHandler(c, o);
            }
         }


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
   public MoveRequestHandler(Connection c, Object o) {
      float x = ((Move4Request) o).x;
      float y = ((Move4Request) o).y;
      CellInstance cell = World.getInstance().getPlayerByConnection(c).getCell();
      if(cell.getEnergy() >= 1)
      {
         cell.setEnergy(cell.getEnergy()-1);
         Move5Answer mans = new Move5Answer();
         mans.accepted = true;
         mans.x = x;
         mans.y = y;
         c.sendTCP(mans);
      }
   }


Here is the client received() code. I even made a log for ANY class that is received. No sign of any packet...

1  
2  
3  
4  
5  
6  
7  
8  
9  
          public void received (Connection connection, Object object) {
            CellClient.window.debug.append(object.getClass().getName() + "!!!\n");
           
            if (object instanceof Login1Answer) {
               new LoginAnswerHandler(object, connection);
            }
            if(object instanceof Move5Answer) {
               new MoveAnswerHandler(object, connection);
            }


here is my client code
here is my server code
here is the NetworkListener class. there is an exact copy of that for client too



What is amazing me is that LoginRequest and LoginAnswer packets are working without any sign of problem, yet MoveAnswer is not received even they are written the same way.

Hope anyone can enlighten me.


EDIT: Forgot about the debug logs, sorry. here they are.
server log
clientlog
Pages: [1]
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Try the Free Demo of Revenge of the Titans

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (63 views)
2013-05-17 21:29:12

alaslipknot (72 views)
2013-05-16 21:24:48

gouessej (103 views)
2013-05-16 00:53:38

gouessej (100 views)
2013-05-16 00:17:58

theagentd (110 views)
2013-05-15 15:01:13

theagentd (100 views)
2013-05-15 15:00:54

StreetDoggy (145 views)
2013-05-14 15:56:26

kutucuk (168 views)
2013-05-12 17:10:36

kutucuk (167 views)
2013-05-12 15:36:09

UnluckyDevil (176 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!
Page created in 0.183 seconds with 21 queries.