- Home /
C# send world data from socket server to client
Hi,
I am working on a project for school. My idea is to make a very basic remake of the game Rust. I started working on the server and client using C# Sockets. So after a while I created a basic server where the clients can connect to and send their transform (position and rotation). But that has nothing to do with my question. What my question is, is how do I send data from objects on the server (trees, rocks, buildings, other players) to the client if the client connects?
Lets take the trees as an example. For the trees, I have a class TreeData, and a script DataStorage. On that DataStorage script I've created a list of TreeData and on the start I add a lot of TreeData's to that list. In that TreeData script I have the following data: treeID, xPos, yPos, zPos.
My question is, is how do I send all that data to the client? The first thing i tried is to loop through every TreeData in the TreeData list. And then for each tree send a seperate packet with all that data to the client. But this did not work. If I did this, the client would lose his connection almost instantly.
Is there a better way of doing this? Or has someone an idea how the original game Rust would handle this?
Thanks for reading! Hope you can understand this. Live in holland so hope my english isn't to bad :) Thanks in advance!
Wiebren