Kryonet packet sending on connection issue!

GameServer.java

http://pastebin.com/Np9Rn4YZ

and

GameClient.java

http://pastebin.com/TL6A1LZL

I’m not exactly sure if anyone here has Kryonet experience but my issue is that the

			public void connected(Connection connection) {
				for (int i = 0; i < 200; i++) {
					if (!(cuboids[i][0] == 0 && cuboids[i][1] == 0
							&& cuboids[i][2] == 0 && cuboids[i][3] == 0
							&& cuboids[i][4] == 0 && cuboids[i][5] == 0)) {
						sendCuboid(connection, cuboids[i][0], cuboids[i][1],
								cuboids[i][2], cuboids[i][3], cuboids[i][4],
								cuboids[i][5]);
					}
				}
				
				System.out.println("Sent all cuboids present");
			}

part of

GameServer.java

will run, however the packets it sends won’t be received by the connected client. I’m really baffled here because the "Sent all cuboids present" string actually shows up in the console output

Thanks if anyone can explain a way around

EDIT: I’ve also tested with 3 clients through the following process;

[quote]Client #1 connects
Client #2 connects

Client #1 places a block
Client #2 and #1 can see it

Client #2 places a block
Client #1 and #2 can see it

Client #3 connects
Client #3 can’t see the two blocks placed
Client #3 places a block

Client #1, #2 and #3 can see it
[/quote]

Are you certain that you are actually sending anything on your connected event?

System.out.println("Sent all cuboids present");

is outside your if statement.

Also, you shouldn’t send each “cuboid” individually; batch them up into one server.sendToTCP call.

I put that to see whether if if the connected function was triggered, I know that it’s not supposed to send anything…

You call a method in the connected event that sends something no?

            for (int i = 0; i < 200; i++) {
               if (!(cuboids[i][0] == 0 && cuboids[i][1] == 0
                     && cuboids[i][2] == 0 && cuboids[i][3] == 0
                     && cuboids[i][4] == 0 && cuboids[i][5] == 0)) {
                  
                  // this guy
                  sendCuboid(connection, cuboids[i][0], cuboids[i][1],
                        cuboids[i][2], cuboids[i][3], cuboids[i][4],
                        cuboids[i][5]);

               }
            }

Do you know for sure that this sendCuboid is actually being called?

Fixed the issue a long time ago, the issue was that I set the connected function after starting the connection so the server connected and then called the default empty connected

The fix is simply setting it before starting the connection