Advertisement Jump to content
Sign in to follow this  

Sending/receiving objects C#

This topic is 2238 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!

Share this post

Link to post
Share on other sites
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.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!