GameShield V5 SDK Programming Guide: gs::TGSDynamicLM Class Reference

GameShield v5 SDK

Base class of Dynamic License Model. More...

Public Member Functions

TGSLicenselicense ()
 Gets the proxy TGSLicense object pointer. More...
 

Protected Member Functions

virtual void init ()
 
Define License Model Parameters
void defineParamStr (const char *paramName, const char *paramInitValue, unsigned int permission)
 
void defineParamInt (const char *paramName, int paramInitValue, unsigned int permission)
 
void defineParamInt64 (const char *paramName, int64_t paramInitValue, unsigned int permission)
 
void defineParamBool (const char *paramName, bool paramInitValue, unsigned int permission)
 
void defineParamFloat (const char *paramName, float paramInitValue, unsigned int permission)
 
void defineParamDouble (const char *paramName, double paramInitValue, unsigned int permission)
 
void defineParamTime (const char *paramName, time_t paramInitValue, unsigned int permission)
 
LM Event handlers

Sub-class overrides these handlers to handle licensing logic events

virtual bool isValid ()
 Is License Valid? More...
 
virtual void startAccess ()
 License starts to work. More...
 
virtual void finishAccess ()
 License stops working. More...
 
virtual void onAction (TGSAction *act)
 Action Processing. More...
 
Constructor and Destructor

Must be protected to stop developer from creating /destroying LM instance directly

DLM can only be created and initialized internally by SDK framework.

 TGSDynamicLM ()
 construcotr
 
virtual ~TGSDynamicLM ()
 destructor
 

Detailed Description

Base class of Dynamic License Model.

Privodes all built-in facilities for DLM development

All dynamic license model should subclass this class.

Subclass of TGSDynamicLM should use DECLARE_LM to define its unique identifier in class declaration, and IMPLEMENT_LM in cpp file to register the DLM class to GS5 kernel.

Example:

in MyLM.h:
class TMyLM : public gs::TGSDynamicLM {
DECLARE_LM(TMyLM, "CAC9EE30-A394-4609-B6BA-3B1FA3F0C60B", "My First LM", "User must log in to play game");
protected:
virtual void init(){
}
bool isValidLogIn(const char* usr, const char* pwd){
LOG("usr [%s] pwd [%s]", usr, pwd);
return (0 == strcmp(usr, "Randy")) && (0 == strcmp(pwd, "abcd1234"));
}
virtual bool isValid(){
return isValidLogIn(license()->getParamStr("UserName").c_str(), license()->getParamStr("Password").c_str());
}
};
in MyLM.cpp:
#include "MyLM.h"
IMPLEMENT_LM(TMyLM);
*

Ref: DLM

Member Function Documentation

void gs::TGSDynamicLM::defineParamBool ( const char *  paramName,
bool  paramInitValue,
unsigned int  permission 
)
protected

Defines Boolean Parameter

Parameters
paramNamethe name of parameter
paramInitValuethe initial parameter value
permissionthe the parameter access control mask (Ref: LMParamAccessCtl)
void gs::TGSDynamicLM::defineParamDouble ( const char *  paramName,
double  paramInitValue,
unsigned int  permission 
)
protected

Defines Double Parameter

Parameters
paramNamethe name of parameter
paramInitValuethe initial parameter value
permissionthe the parameter access control mask (Ref: LMParamAccessCtl)
void gs::TGSDynamicLM::defineParamFloat ( const char *  paramName,
float  paramInitValue,
unsigned int  permission 
)
protected

Defines Float Parameter

Parameters
paramNamethe name of parameter
paramInitValuethe initial parameter value
permissionthe the parameter access control mask (Ref: LMParamAccessCtl)
void gs::TGSDynamicLM::defineParamInt ( const char *  paramName,
int  paramInitValue,
unsigned int  permission 
)
protected

Defines 32bit Integer Parameter

Parameters
paramNamethe name of parameter
paramInitValuethe initial parameter value
permissionthe the parameter access control mask (Ref: LMParamAccessCtl)
void gs::TGSDynamicLM::defineParamInt64 ( const char *  paramName,
int64_t  paramInitValue,
unsigned int  permission 
)
protected

Defines 64bit Integer Parameter

Parameters
paramNamethe name of parameter
paramInitValuethe initial parameter value
permissionthe the parameter access control mask (Ref: LMParamAccessCtl)
void gs::TGSDynamicLM::defineParamStr ( const char *  paramName,
const char *  paramInitValue,
unsigned int  permission 
)
protected

Defines String Parameter

Parameters
paramNamethe name of parameter
paramInitValuethe initial parameter value
permissionthe the parameter access control mask (Ref: LMParamAccessCtl)
void gs::TGSDynamicLM::defineParamTime ( const char *  paramName,
time_t  paramInitValue,
unsigned int  permission 
)
protected

Defines Time Parameter

Parameters
paramNamethe name of parameter
paramInitValuethe initial parameter value
  It is the number of seconds elapsed since 00:00 hours, Jan 1, 1970 UTC (i.e., a unix timestamp).   
permissionthe the parameter access control mask (Ref: LMParamAccessCtl)
void gs::TGSDynamicLM::finishAccess ( )
protectedvirtual

License stops working.

Called when the entity the license attached to enters In-Active status; the gsEndAccess() triggers this event

It is a great chance to release any local resources used in licensing logic.

void gs::TGSDynamicLM::init ( )
protectedvirtual

Initialize the DLM instance

Subclass should override this method to initialize itself (defines LM parameters, etc.)

bool gs::TGSDynamicLM::isValid ( )
protectedvirtual

Is License Valid?

Returns
true if the license is still valid.

This function is called periodically by GS5 kernel to query the current license status.

The entity might not be active, i.e., the startAccess() might not have been called, so please make sure the function implementation should not assume that the startAccess() was called before.

TGSLicense* gs::TGSDynamicLM::license ( )
inline

Gets the proxy TGSLicense object pointer.

The returned TGSLicense object is created automatically when the LM instance is created, it acts as proxy to access LM's parameters.

void gs::TGSDynamicLM::onAction ( TGSAction act)
protectedvirtual

Action Processing.

Parameters
actaction being applied

Called when an action is applied to this license. GS5 has processed all commonly used actions (ACT_UNLOCK, ACT_LOCK, ACT_CLEAN, etc.) before this method is called so you will not see these actions passed in, you only need to deal with LM-specific actions that other action processors do not understand.

void gs::TGSDynamicLM::startAccess ( )
protectedvirtual

License starts to work.

Called when the entity the license attached to enters Active status. that is, the gsBeginAccess() is called and the entity accessing is approved by its attached license(s).

It is a great chance to start any internal timing logic, or initialize local data resources.

Generated on Mon Feb 3 2014 13:15:30 for GameShield V5 SDK Programming Guide by   doxygen 1.8.5