Пример #1
0
    h2ext.regTimer(1000, timer_cb)
def dbTest():
    dbhost = "mysql://127.0.0.1:3306/root/rootpassword/dbname"
    dbid   = h2ext.connectDB(dbhost, 'TestGroup')
    def cb(ret):
        print('cb', ret)
        return
    h2ext.asyncQuery(dbid, 'select * from user_log limit 1', cb)   #async
    ret = h2ext.query(dbid, 'select * from user_log limit 1')       #sync

print('main.py'+'*'*10)
def httpcb(retdata):
    print('httpcb', retdata)
#h2ext.asyncHttp("http://www.baidu.com", 1, httpcb)
def when_syncSharedData(cmd, data):
    print('when_syncSharedData', cmd, data)
  
#ret = h2ext.callFunc("Entity.totalNum")
#print('ret', type(ret), ret)
def testScriptCall(arg1 = 0, arg2 = 0, arg3 = 0, arg4 = 0, arg5 = 0, arg6 = 0, arg7 = 0, arg8 = 0, arg9 = 0):
    print('testScriptCall', arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9)
    return 1122334
h2ext.callFunc("Cache.set", "b", "bbbb")
h2ext.callFunc("Cache.set", "m.n[10]", "mmm1")
cacheRet = h2ext.callFunc("Cache.get", "m.n[0]")
print("cacheRet", cacheRet)
multigetRet = h2ext.callFunc("Cache.multiget", ["m.n", "b"])
print("multigetRet", multigetRet)
cacheRet = h2ext.callFunc("Cache.get", "")
print("cacheRet", cacheRet, h2ext.callFunc("Cache.size", "m"), h2ext.callFunc("Cache.size", "m.n"))
Пример #2
0
def testTask(entity):
    h2ext.callFunc(
        "Task.addTaskCfg", {
            "cfgid": 1,
            "taskLine": 2,
            "nextTask": 2,
            "finishConditionType": "killMonster",
            "finishConditionObject": "cat",
            "finishConditionValue": 1
        })
    h2ext.callFunc(
        "Task.addTaskCfg", {
            "cfgid": 2,
            "taskLine": 2,
            "nextTask": 0,
            "finishConditionType": "killMonster",
            "finishConditionObject": "dog",
            "finishConditionValue": 1
        })
    taskCfg = h2ext.callFunc("Task.getTaskCfg", 1)
    print("taskCfg", taskCfg)
    h2ext.callFunc("Task.genTask", entity, 1)
    h2ext.callFunc("Task.acceptTask", entity, 1)
    h2ext.callFunc("Task.triggerEvent", entity, 'killMonster', 'cat', 1)
    h2ext.callFunc("Task.endTask", entity, 1)
    allTask = h2ext.callFunc("Task.getTask", entity, 2)
    print("testTask allTask", allTask)
    return