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.
@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;
}
}
}
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.
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);
}
}
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…
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