What is an extensible way to implement server-side command processing in MMORPG?

Update: I apologize if maybe my question is not clear enough. I read about the command template, but unfortunately did not use it myself. I'm trying to figure out how I can use it (or some other template) to make game events abstract so that the server can handle them with one Process () method. My main hang here is to make sure that game events get enough information to actually do what they need to do (for example, log in to the user’s system and add them to the list of active users, send card data, move the player, etc. .). A relevant example would be greatly appreciated.

I am new to game development, but decided to start working on a (relatively) simple 2D MMORPG in my free time. I would consider myself a very capable programmer, and I have a good foundation of skills, but I am still struggling with some of the projects related to playing on a client-server server. In particular, I hardly think of an extensible way of processing commands. Let me introduce a functional example:

Login

  • Beginning of the game
  • Click Continue
  • Enter username and password
  • Click Sign In
  • See the symbol wherever you are when you log out

From a client-server architecture perspective, here's what I'm doing right now:

[Client]

  • Send SimpleTextNetworkMessage to the server - {LogInRequest, UN: [UserName] | PW: [Password]}
  • Darken the user interface and wait for a response (timeout: 10 seconds)
  • Get SimpleTextNetworkMessage from the server - {LogInSuccessResponse, [Player ID]}
  • Send SimpleTextNetworkMessage to the server - {GetPlayerInfoRequest, [player ID]}
  • Get SimpleDataNetworkMessage from the server - {GetPlayerInfoResponse, [Player Information]}
  • Send SimpleTextNetworkMessage to the server - {GetMapInfoRequest, [player ID]}
  • Get SimpleDataNetworkMessage from the server - {GetMapInfoResponse, [MapData]}
  • Draw a screen

In my example, three key events are indicated:

Login

Confirm the information provided by the user, download the player information from the database (HP, MP, latest location, etc.) and map the player to the map and connection.

Get player info

Send back information about the player’s statistics, equipment, experience, current card identifier and any other that should be displayed in the user interface.

Get map information

Send information to the player about all tiles within a radius of 50 tiles ... this should include information about fragments for a three-layer map, as well as the locations and names of NPCs / monsters / players; when a player moves, additional information about the map will be requested / updated.

You can see that each of these processes is different and requires different information. On the server side, how can I do something like:

while (ServerIsRunning) { foreach (Client c in clients) { eventQueue.AddList(c.ReceiveAll()); } foreach(GameEvent event in eventQueue) { event.Process(); } int[] keys = messageQueue.Keys; foreach (int key in keys) { Client c = clients.Get(key); foreach(NetworkMessage message in messageQueue[key]) { c.Send(message); } } } 
+6
c # architecture
source share
1 answer

When I read what you ask, you seem to be asking for an "extensible way to implement command processing."

From the way you express it, your query obviously points to a Command Pattern .

I'm not a C # person, so unfortunately I can’t do most of the work evaluating the many offers Google offers. Here you are to get you started. http://www.c-sharpcorner.com/UploadFile/cupadhyay/CommandPatternsInCS11142005021734AM/CommandPatternsInCS.aspx

+1
source share

All Articles