I'm writing the server for my game, but have run into a problem. The clients connect correctly, however in Lidgren's examples he interfaces with each connection *directly* through a connections property in the server class. The example gets away with this because all he's doing is moving a sprite around the screen. Unfortunately this isn't suitable for my setup as the complexity of my game demands that I interface with the class instance behind the sprite, and not with the socket connection directly. I read something about a 'command structure' setup where every time a new player connects, a new instance of a 'player' class is created, and the actual socket connection resides within that class. The result is that interfacing with each connection is simple, clean and efficient.
Now that's all well and good in theory, but I've been racking my brain now for a couple days trying to figure out just *how* to do it. I have the server spawning a new player class every time a connection happens, but I'm quite stuck on the logic of how to bind that particular instance to the connection that just arrived, because the list of connections seems to be buried in server.Connections. The documentation hasn't proven terribly helpfull either.
I'm not sure if I've explained it clearly, but basically I'm not sure how to differentiate between connections in server.Connections so that I can bind, say, player to it's corresponding connection in server.Connections. This way, I can say things like, "players.SendMessage(whatever);" etc rather than having to do it all messy like.
Anyone familiar with this sort of thing?
"None are more hopelessly enslaved than those who falsely believe they are free."
"It is no measure of health to be well adjusted to a profoundly sick society."
"Hope is the first step on the road to dissapointment." -Jonah Orionhttp://tankzgame.blogspot.com