Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Sending/Receiving object/references or part of Object with JavaNio.  RSS feed

 
Jibby Lala
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,

i have designed a real time Physics simulation with javanio , which is about moving balls simultaneously (real time) on multiple clients

Currently, i m sending the coordinates of one ball with string parsing, but now i want to move multiple balls and want to have some generic mechanism other than sending string, so i create 4 balls on server.

how i can realized, so that coordinates of each ball correspond to same ball on client (which i created on client too), and each ball can be move according to its received coordinates from the sever.

This should be realized by sending the reference of each ball but i don't have idea how to realized that with java byte buffer and with javanio overall.

i have the problem with implementation, if somebody help me with code example , it would be great, anyway which can be generic for sending simulation data like object coordinates other than strings can be acceptable but it should implement the usecase as i described.

Thanks,

Jibbylala
cross post:http://stackoverflow.com/questions/5370279/sending-receiving-object-references-or-part-of-object-with-javanio
 
Jim Hoglund
Ranch Hand
Posts: 525
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Others will have ideas too, but I have been working with RMI (remote methods)
lately and this sounds like a good problem for RMI. How many balls and how
many clients will you be using?

Jim ...
 
Jibby Lala
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply, i already use the RMI with the same logic, i was sending the whole ball object on wire serialized, i wanted to make scalable network and that's why started using javaNio because you know what could be the liabilities with RMI for big application where large size and large number of object needs to be serialized.

It's not about balls its about any object any number ofcourse not 100 but 20 30 or 50 in simulation, this ball simulation i want to made this balls simulation as example for the other simulation so there should be some generic mechanism.
 
Jim Hoglund
Ranch Hand
Posts: 525
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you post code so that I can see your RMI based solution? If you need only
hundreds of objects, and they are not seriously complex, RMI should work fine.
It offers a lot of easy-to-use features for synchronizing your clients. Is there a
specific problem you have seen hthat makes RMI unsuitable?

Jim ...
 
Jibby Lala
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I really cordially appreciate your interest, but this work is part of my thesis, as i told i already made that simulation with RMI and closed that chapter by saying that RMI was good so we used that in our first iteration and RMI has these these problems so we are telling the alternative, and then i choose the javanio


but i have problem with it now as realization is concerned if you could help in that i will be really thankful, nevertheless i can share my RMI project with you but my task these days to implement realtime simulation with javanio infact as i said my design with string base is already running (one ball which is running from server who is sending coordinate as string now i want more balls so i have problem to send the coordinate for each ball and receiving the same on client to draw while there are no reference attach to those which ball correspond to which ball on client) but i need little bit generic solution which can be valid for other simulations too, RMI was it's self generic so it didn't take to much effort,but i really need the second alternative for second iteration and to show the other possibility in my thesis.

The scenario i told is really generic ,i wondered how other people realized their network game, i know but still surprised is it really that much work to implement that functionality with javanio.
 
Jibby Lala
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i saw this post:http://www.coderanch.com/t/276259/Streams/java/Convert-ByteBuffer-object

they are sending the whole object but i just wanted to send
Ball[i].X ,Ball[i].Y and receive the same at client site
 
Jim Hoglund
Ranch Hand
Posts: 525
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you considered adding XML tags to your data stream? You can
label your X/Y value pairs and include meta-data to keep things
organized. And it's all readable which will help with debugging.

Jim ...
 
Jibby Lala
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No i don't have idea about this approach and how it will be realized.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!