Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (525)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (594)
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  
  Game Networking Framework  (Read 857 times)
0 Members and 1 Guest are viewing this topic.
Offline RedXVIII

Junior Newbie





« Posted 2014-04-07 18:30:14 »

So I have an issue with working with UDP Socketing. The problem is in my Game Engine, I send over information about a Game Object from the Server to the Client, and if that Game Object doesn't exist, I would create one, but the problem is that every class is different, and has a different constructor, so creating a new object would be difficult. how would I fix this problem?  Undecided
Offline opiop65

JGO Kernel


Medals: 159
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #1 - Posted 2014-04-07 18:42:11 »

So... Why don't you send over the constructor's parameters?

Offline RedXVIII

Junior Newbie





« Reply #2 - Posted 2014-04-07 18:48:04 »

Would you give an example please?   Shocked
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Online SilverTiger

Junior Devvie


Medals: 5
Exp: 2 years


がんばってください!


« Reply #3 - Posted 2014-04-07 19:12:58 »

Well when I worked with a Client-Server-System the Server send messages in some pseudo XML, something like this:
1  
2  
3  
4  
5  
6  
7  
8  
begin:foobar
begin:intlist
0
1
2
end:intlist
length: 3
end:foobar


So let's assume you have a Player class with an ID, x, y, hp and mp. Your server messages could look like this:
1  
2  
3  
4  
5  
6  
7  
begin:player
id:1234
x:5
y:8
hp:321
mp:234
end:player

After that you could parse that messages, possibly with a recursive descent parser.
You could also send a message "Player(1234,5,8,321,234)", you just have to know how to parse your message for the constructor.

Does that help? Smiley
Online matheus23

JGO Kernel


Medals: 113
Projects: 3


You think about my Avatar right now!


« Reply #4 - Posted 2014-04-07 19:24:36 »

I highly suggest to use Kryonet. It allows sending java objects over the internet via TCP / UDP with a lot of useful optimizations. It's pretty much the fastest Serialization library (Kryo) together with a very fast network implementation.

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

Junior Newbie





« Reply #5 - Posted 2014-04-07 20:35:18 »

I'm going to keep doing my own socketing so that I can use it at it's fullest. @Silver Tiger, sadly that did not help, I had something similar to that already setup. Please read the main topic more.

P.S. Not trying to be a dick, I appreciate your time, and effort.
Offline ctomni231

JGO Wizard


Medals: 99
Projects: 1
Exp: 7 years


Not a glitch. Just have a lil' pixelexia...


« Reply #6 - Posted 2014-04-07 20:48:55 »

So, basically, you want to send Objects over to the server regardless of the structure, store them, and be able to read them back with no questions asked. Maybe some more information about these Objects would help people a little more. Try answering these questions...

1) Do these Objects have a maximum size?
2) Does data loss of these objects matter?

To be honest, the request sounds unreasonable for UDP. I believe researching how to use Kyronet would be the correct solution as you are heavily hinting at serialization and storage. At least, in this case, you'd be able to handle new requests client side. The server can care less what data is stored, it is just up to the client to keep track on where to look for data when it is on the server.

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.

toopeicgaming1999 (68 views)
2014-11-26 15:22:04

toopeicgaming1999 (58 views)
2014-11-26 15:20:36

toopeicgaming1999 (13 views)
2014-11-26 15:20:08

SHC (26 views)
2014-11-25 12:00:59

SHC (24 views)
2014-11-25 11:53:45

Norakomi (30 views)
2014-11-25 11:26:43

Gibbo3771 (24 views)
2014-11-24 19:59:16

trollwarrior1 (37 views)
2014-11-22 12:13:56

xFryIx (76 views)
2014-11-13 12:34:49

digdugdiggy (53 views)
2014-11-12 21:11:50
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
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!