Here we will talk about the code of the Process part of Firefly's "Dark World" fragment merging. This is mainly the part of message parsing. Let's get the code and the code path is APP/GAME/gatenodeapp/compound. py.
- # Coding: utf8
- '''
- Created on 2013-3-21
- Product Merging
- @ Author: Lan (www.9miao.com)
- '''
- From app. Game. gatenodeservice import remoteservicehandle
- Import JSON
- # Import function logic processing module
- From app. Game. appinterface import Compound
-
- @ Remoteservicehandle # Add the processing method to the service for the gateserver process to call.
- Def getcompoundpackage_2109 (dynamicid, request_proto ):
- ''' Get the merged package information
- '''
- # Parsing JSON strings
- Argument = JSON. Loads (request_proto)
- # Obtain the role ID
- Characterid = argument. Get ('characterid ')
- # Obtain the merged package information
- Response = compound. getcompoundpackage_2109 (dynamicid, characterid)
- # Serialize information, generate a JSON string, and return it to the client
- Return JSON. dumps (response)
-
- @ Remoteservicehandle # Add the processing method to the service for the gateserver process to call.
- Def getoneiteminfo_211 (dynamicid, request_proto ):
- '''Get the information of a single item
- '''
- # Parsing JSON strings
- Argument = JSON. Loads (request_proto)
- # Obtain the role ID
- Characterid = argument. Get ('characterid ')
- # Obtain the instance id of an item
- Itemid = argument. Get ('itemid ')
- # Retrieving item information
- Response = compound. getoneiteminfo (dynamicid, characterid, Itemid)
- # Serialize information, generate a JSON string, and return it to the client
- Return JSON. dumps (response)
- @ Remoteservicehandle # Add the processing method to the service for the gateserver process to call.
- Def getcompounditem_205 (dynamicid, request_proto ):
- "Gets information about the items that can be merged by the current Fragment
- """
- # Parsing JSON strings
- Argument = JSON. Loads (request_proto)
- # Obtain the role ID
- Characterid = argument. Get ('characterid ')
- # Obtain the model ID of the item to be merged
- Tempid = argument. Get ('tempid ')
- # Obtain information about the items that can be merged by the current Fragment
- Response = compound. getcompounditem (dynamicid, characterid, tempid)
- # Serialize information, generate a JSON string, and return it to the client
- Return JSON. dumps (response)
-
- @ Remoteservicehandle # Add the processing method to the service for the gateserver process to call.
- Def compounditem_2116 (dynamicid, request_proto ):
- ''' Composite item
- '''
- # Parsing JSON strings
- Argument = JSON. Loads (request_proto)
- # Obtain the role ID
- Characterid = argument. Get ('characterid ')
- # Obtain the model ID of the item to be merged
- Tempid = argument. Get ('tempid ')
- # Merging an item and returning the merged result
- Response = compound. compounditem (dynamicid, charac terid, tempid)
- # Serialize information, generate a JSON string, and return it to the client
- Return JSON. dumps (response)
-
Copy code
Does not perform actual logic processing, but does parse the parameters sent from the client. To replace the communication message format, the logic processing part of the code is not affected. Messages are transmitted to the gateserver through NETServer, which is distributed to the specified gameserver. The gameserver enters the corresponding processing method through the command number.