KBEngine |
KBEngine module
This KBEngine module mainly handles access of third-party platforms for the KBEngine server.Member functions
def addTimer( initialOffset, repeatOffset=0, callbackObj=None ): |
def accountLoginResponse( commitName, realAccountName, extraDatas, errorCode ): |
def createAccountResponse( commitName, realAccountName, extraDatas, errorCode ): |
def chargeResponse( orderID, extraDatas, errorCode ): |
def delTimer( id ): |
Callbacks
def onInterfaceAppReady( ): |
def onInterfaceAppShutDown( ): |
def onRequestCreateAccount( registerName, password, datas ): |
def onRequestAccountLogin( loginName, password, datas ): |
def onRequestCharge( ordersID, entityDBID, datas ): |
Member functions documentation
def addTimer( initialOffset, repeatOffset=0, callbackObj=None ):
Function description:
Registers a timer. The timer triggers the callback function callbackObj. The callback function will be executed the first time after "initialOffset" seconds, and then will be executed once every "repeatOffset" seconds.
Example:
Registers a timer. The timer triggers the callback function callbackObj. The callback function will be executed the first time after "initialOffset" seconds, and then will be executed once every "repeatOffset" seconds.
Example:
# Here is an example of using addTimer import KBEngine # Add a timer, perform the first time after 5 seconds, and execute once every 1 second. The user parameter is 9 KBEngine.addTimer( 5, 1, onTimer_Callbackfun ) # Add a timer and execute it after 1 second. The default user parameter is 0. KBEngine.addTimer( 1, onTimer_Callbackfun ) def onTimer_Callbackfun( id ): print "onTimer_Callbackfun called: id %i" % ( id ) # If this is a repeated timer, it is no longer needed, call the following function to remove: # KBEngine.delTimer( id )
parameters:
initialOffset | float, specifies the time interval in seconds for the timer to register from the first callback. |
repeatOffset | float, specifies the time interval (in seconds) between each execution after the first callback execution. You must remove the timer with the function delTimer, otherwise it will continue to repeat. Values less than or equal to 0 will be ignored. |
callbackObj | function, the specified callback function object |
returns:
integer, the internal id of the timer. This id can be used to remove the timer from delTimer. |
def accountLoginResponse( commitName, realAccountName, extraDatas, errorCode ):
Function description:
After onRequestAccountLogin is called back, the script needs to call this function to give the result of the login processing.
After onRequestAccountLogin is called back, the script needs to call this function to give the result of the login processing.
parameters:
commitName | string, the name submitted by the client when requested. |
realAccountName | string, returns the real account name (if there are no special requirements it is ually commitName, this is available when logging in with various alias accounts). |
extraDatas | bytes, the data attached to the client's request. Can forward the data to a third-party platform and provide an opportunity to modify it. This parameter can be read in the script via the getClientDatas interface of the base entity. |
errorCode | integer, error code. If you need to interrupt the user's behavior, you can set the error code here. The error code can be referenced (KBEngine.SERVER_ERROR_*, described in kbengine/kbe/res/server/server_errors.xml), otherwise submitting KBEngine.SERVER_SUCCESS represents permitting the login. |
def createAccountResponse( commitName, realAccountName, extraDatas, errorCode ):
Function description:
After onRequestCreateAccount is called back, the script needs to call this function to give an account creation processing result.
After onRequestCreateAccount is called back, the script needs to call this function to give an account creation processing result.
parameters:
commitName | string, the name submitted by the client when requested. |
realAccountName | string, returns the real account name (if there are no special requirements it is ually commitName, this is available when logging in with various alias accounts). |
extraDatas | bytes, the data attached to the client's request. Can forward the data to a third-party platform and provide an opportunity to modify it. This parameter can be read in the script via the getClientDatas interface of the base entity. |
errorCode | integer, error code. If you need to interrupt the user's behavior, you can set the error code here. The error code can be referenced (KBEngine.SERVER_ERROR_*, described in kbengine/kbe/res/server/server_errors.xml), otherwise submitting KBEngine.SERVER_SUCCESS represents permitting the login. |
def chargeResponse( orderID, extraDatas, errorCode ):
Function description:
After onRequestCharge is called back, the script needs to call this function to give the billing result.
After onRequestCharge is called back, the script needs to call this function to give the billing result.
parameters:
ordersID | string, the ID of the order |
extraDatas | bytes, the data attached to the client's request. Can forward the data to a third-party platform and provide an opportunity to modify it. This parameter can be read in the script via the getClientDatas interface of the base entity. |
errorCode | integer, error code. If you need to interrupt the user's behavior, you can set the error code here. The error code can be referenced (KBEngine.SERVER_ERROR_*, described in kbengine/kbe/res/server/server_errors.xml), otherwise submitting KBEngine.SERVER_SUCCESS represents permitting the login. |
def delTimer( id ):
Function description:
The delTimer function is used to remove a registered timer. The removed timer is no longer executed. Single-shot timers are automatically removed after the callback is executed, and it is not necessary to use the delTimer function to remove it. If the delTimer function is passed an invalid id (for example, timer was removed), it will generate an error.
A use case is shown in the KBEngine.addTimer example.
The delTimer function is used to remove a registered timer. The removed timer is no longer executed. Single-shot timers are automatically removed after the callback is executed, and it is not necessary to use the delTimer function to remove it. If the delTimer function is passed an invalid id (for example, timer was removed), it will generate an error.
A use case is shown in the KBEngine.addTimer example.
parameters:
id | integer, which specifies the timer id to remove. |
Callback functions documentation
def onInterfaceAppReady( ):
Function description:
This function is called back when the current process is ready.
Note: This callback interface must be implemented in the portal module ( kbengine_defaults.xml ->entryScriptFile).
This function is called back when the current process is ready.
Note: This callback interface must be implemented in the portal module ( kbengine_defaults.xml ->entryScriptFile).
def onInterfaceAppShutDown( ):
Function description:
This function is called back when the process shuts down.
Note: This callback interface must be implemented in the portal module ( kbengine_defaults.xml ->entryScriptFile).
This function is called back when the process shuts down.
Note: This callback interface must be implemented in the portal module ( kbengine_defaults.xml ->entryScriptFile).
def onRequestCreateAccount( registerName, password, datas ):
Function description:
This callback is called when the client requests the server to create an account.
The data can be checked and modified within this function, and the final result is submitted to the engine through KBEngine.createAccountResponse.
Note: This callback interface must be implemented in the portal module ( kbengine_defaults.xml ->entryScriptFile).
This callback is called when the client requests the server to create an account.
The data can be checked and modified within this function, and the final result is submitted to the engine through KBEngine.createAccountResponse.
Note: This callback interface must be implemented in the portal module ( kbengine_defaults.xml ->entryScriptFile).
parameters:
registerName | string, the name submitted by the client when requested. |
password | string, password |
datas | bytes, the data attached to the client's request, can forward data to a third-party platform. |
def onRequestAccountLogin( loginName, password, datas ):
Function description:
This callback is called when the client requests the server to login an account.
The data can be checked and modified within this function, and the final result is submitted to the engine through KBEngine.accountLoginResponse.
Note: This callback interface must be implemented in the portal module ( kbengine_defaults.xml ->entryScriptFile).
This callback is called when the client requests the server to login an account.
The data can be checked and modified within this function, and the final result is submitted to the engine through KBEngine.accountLoginResponse.
Note: This callback interface must be implemented in the portal module ( kbengine_defaults.xml ->entryScriptFile).
parameters:
loginName | string, the name submitted by the client when requested. |
password | string, password. |
datas | bytes, the data attached to the client request, can forward data to a third-party platform. |
def onRequestCharge( ordersID, entityDBID, datas ):
Function description:
This callback is invoked when billing is requested (usually KBEngine.charge is called on baseapp).
Data can be checked and modified within this function, and the final result is submitted to the engine via KBEngine.chargeResponse.
Note: This callback interface must be implemented in the portal module ( kbengine_defaults.xml ->entryScriptFile).
This callback is invoked when billing is requested (usually KBEngine.charge is called on baseapp).
Data can be checked and modified within this function, and the final result is submitted to the engine via KBEngine.chargeResponse.
Note: This callback interface must be implemented in the portal module ( kbengine_defaults.xml ->entryScriptFile).
parameters:
ordersID | uint64, the ID of the order. |
entityDBID | uint64, the entity DBID of the submitted order. |
datas | bytes, the data attached to the client request, can forward data to a third-party platform. |