Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (476)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (533)
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] Sending an int[][] over KryoNet  (Read 3312 times)
0 Members and 1 Guest are viewing this topic.
Offline marcuiulian13

Senior Member


Medals: 5
Exp: 3 years



« Posted 2012-08-19 23:03:52 »

Good evening.
I am trying to send a int[][] from server to client using Kryonet. The size of array is 256x256, but is the same if i use an 1x1 array.
The problem is that if i try to send the "Level" object, the connection stops (after x seconds, the client is disconnected, but server still thinks that he is still connected). I have tried using a byte[][] and a byte[], but nothing changes. The array values are between 0 and 6.

This is my Object:
1  
2  
3  
public static class Packet0Level {
   public int[][] map;
}

Getting a project done is by far the most hard thing in game development.
Offline Danny02
« Reply #1 - Posted 2012-08-19 23:37:06 »

quite funny to use a serialization library to serialize a byte array into a byte array
Offline marcuiulian13

Senior Member


Medals: 5
Exp: 3 years



« Reply #2 - Posted 2012-08-20 00:23:35 »

Okay, now i'm trying to send to the client data about every tile, using a for. The error i get is:

1  
2  
3  
4  
5  
6  
Exception in thread "pool-1-thread-1" java.lang.NullPointerException
   at com.minier.network.NetworkListener.received(NetworkListener.java:27)
   at com.esotericsoftware.kryonet.Listener$QueuedListener$3.run(Listener.java:102)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)


And here is the code at line 27:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
public void received(Connection c, Object o) {
      if(o instanceof Packet0LevelInfo) {
         Packet0LevelInfo packet = (Packet0LevelInfo) o;
         Launcher.level = new Level(packet.levelWidth, packet.levelHeight);
      } else if(o instanceof Packet1LevelData) {
         Packet1LevelData packet = (Packet1LevelData) o;
/*LINE 27*/   Launcher.level.getMap()[packet.tileX][packet.tileY] = packet.tile; /*LINE 27*/
      } else if(o instanceof Packet2LevelFinished) {
         Launcher.levelLoaded = true;
      }
   }

Getting a project done is by far the most hard thing in game development.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Nate

JGO Kernel


Medals: 145
Projects: 4
Exp: 14 years


Esoteric Software


« Reply #3 - Posted 2012-08-20 00:27:23 »

I don't see an int[][] in the code you posted.

Offline OttoMeier

Senior Member


Medals: 4
Projects: 1



« Reply #4 - Posted 2012-08-20 00:35:03 »

so any of Launcher.level.getMap() is null. Set a breakpoint at that line to figure out which one.

I dont know if kryo have default support for arrays at the worst you have to write a custom Serializer.
 http://code.google.com/p/kryo/#KryoSerializable
probably you just need something like this:
1  
2  
...
kryo.register(int[].class);

Offline marcuiulian13

Senior Member


Medals: 5
Exp: 3 years



« Reply #5 - Posted 2012-08-20 00:56:34 »

Already tried this...

Getting a project done is by far the most hard thing in game development.
Offline matheus23

JGO Kernel


Medals: 106
Projects: 3


You think about my Avatar right now!


« Reply #6 - Posted 2012-08-22 10:03:00 »

I dont know if kryo have default support for arrays at the worst you have to write a custom Serializer.
This should drive Nate insane... maybe not...

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Offline OttoMeier

Senior Member


Medals: 4
Projects: 1



« Reply #7 - Posted 2012-08-22 13:15:40 »

why?
Offline matheus23

JGO Kernel


Medals: 106
Projects: 3


You think about my Avatar right now!


« Reply #8 - Posted 2012-08-22 20:44:57 »

quite funny to use a serialization library to serialize a byte array into a byte array

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Offline marcuiulian13

Senior Member


Medals: 5
Exp: 3 years



« Reply #9 - Posted 2012-08-26 00:37:58 »

Ok. Thank you. I already solved the problem.
The problem was that the array was too big for client so i broke it into smaller chunks that are sent one after other.  Grin

Getting a project done is by far the most hard thing in game development.
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.

pw (22 views)
2014-07-24 01:59:36

Riven (20 views)
2014-07-23 21:16:32

Riven (17 views)
2014-07-23 21:07:15

Riven (20 views)
2014-07-23 20:56:16

ctomni231 (48 views)
2014-07-18 06:55:21

Zero Volt (44 views)
2014-07-17 23:47:54

danieldean (35 views)
2014-07-17 23:41:23

MustardPeter (38 views)
2014-07-16 23:30:00

Cero (53 views)
2014-07-16 00:42:17

Riven (52 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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!