c# - Sharing code between client and server to remove dependency on each other -
I am developing a multiplayer game in C # and XNA that includes a client and server project. Most codes have been built within the Customer project (server side verification is still being done), so the server executable client should be in the same directory while running. The reason (not a big issue, but unusual for the application) is because the server ( I thought the rational idea code should be separated into 3 parts: The server must be able to run a In this example, I have started creating a "shared" class library that uses both client and server < / p> My problems such as How should I go about separating classes like this? My idea was to either have an interface or intangible class to handle the base (ex: player list, current situation, player's position), and server and client implement their code based on their need. (Eg: the client will implement methods to attract maps, and the server can implement methods to see the player ID required to send the message) My question is: < / Strong> How can I effectively separate the code from the client and server, so I just have to write it once, but both should be able to implement custom functionality, without having to depend on each other For areas? I should mention the project, if you want to make it better. If I understand your question correctly, it seems that you share a The right way to look at the heritage is going down to form a resource library and solve your problem. If a class like a map or player actually has general functionality in the implementation of both the client and the server, then an abstract class seems like going on the right track. I know that I have some projects that have such common functionality that we fulfill in this way. GameName.Server ) has the context of the
GameName.Client namespace, which is the second Is within the project
a "???" One "????" Line Customer ??? Entities A â â ???? An "F" an "app", "app", "player c" is an interface one ???? Line Line One "????" Line Line Line Line Line "Networking" ??? One "????" Line Line Line Line Line MessageHandler.cs source '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' Line Line Line Line Line LoginPacket.cs A world - a ?? one one "????" Line Line Line Line Line Tile type cac ???? Line Line A server ??? One "????" A "Message" Handsler.cs ???? A program that is a program. Other server content, etc etc
map internally, which consists of an array of players and blocks which As you can see, there is no code map in it, this client is in the project.
Map , the rendering code to attract the map is also included on the client (the server does not use these methods, yet it is the same
map uses class)
map or
player Ote are (in the case of a map), the list of players. A list of players can be shared both client and server side, however, what about things like a minimap? The server does not really need a minimap or rendering code, which is only necessary to display the map on the client.
Comments
Post a Comment