Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (581)
games submitted by our members
Games in WIP (500)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  [Kryonet] Client does not receive packet.  (Read 598 times)
0 Members and 1 Guest are viewing this topic.
Offline doizece

Innocent Bystander





« Posted 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]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

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

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (55 views)
2014-04-15 18:08:23

BurntPizza (53 views)
2014-04-15 03:46:01

UprightPath (66 views)
2014-04-14 17:39:50

UprightPath (49 views)
2014-04-14 17:35:47

Porlus (66 views)
2014-04-14 15:48:38

tom_mai78101 (90 views)
2014-04-10 04:04:31

BurntPizza (151 views)
2014-04-08 23:06:04

tom_mai78101 (247 views)
2014-04-05 13:34:39

trollwarrior1 (204 views)
2014-04-04 12:06:45

CJLetsGame (211 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
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!