Sending/receiving objects C#

Started by
0 comments, last by hplus0603 11 years, 4 months ago
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!
Advertisement
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 };

This topic is closed to new replies.

Advertisement