Jump to content

  • Log In with Google      Sign In   
  • Create Account


Sending/receiving objects C#


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 brokilodeluxe   Members   -  Reputation: 115

Like
0Likes
Like

Posted 04 December 2012 - 01:53 AM

So I've got the basic server and client set up for my game. (C# using XNA, lidgren for networking). I can connect and send/receive integers, which is great. You obviously can't typecast whole objects as bytes and transfer them, though.

My game is set up (as I assume most games are) as a list of entities. Each entity has data like position, current frame, etc. that are important to drawing them to the client screens. Here are my options transferring data from server to client, unless there's a (hopefully) easier way:

1) Traverse the entity list on the server, write only data important to the client to the message, and then upon receiving the data, the client traverses the list and backwards engineers the level before drawing it.

2) For each client, draw the level on the server and somehow send the pixel data so the client can draw it (I have no idea how to do this)

3) Maybe there is a way to send whole objects in messages.

Please tell me if I'm on the right track and thank you in advance!

Sponsor:

#2 hplus0603   Moderators   -  Reputation: 5154

Like
0Likes
Like

Posted 04 December 2012 - 12:07 PM

Some variant of 1) is typically what most games do.

You *can* do 3 (with "object serialization") but that's typically only used for enterprise applications, as the serialization tends to be highly inefficient for games.

enum Bool { True, False, FileNotFound };




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS