I have tried to port over the code in "8.18 Server side scheduler" to python, and came very close, but can't get past a certain part.
I can't make a ITaskHandler class... it gives me error:
Traceback (innermost last):
File "<string>", line 863, in init
TypeError: can't instantiate interface (it.gotoandplay.smartfoxserver.util.scheduling.ITaskHandler)
08:45:51.892 - [ WARNING ] > Error in extension [ game.py ]: Traceback (innermost last):
File "<string>", line 863, in init
TypeError: can't instantiate interface (it.gotoandplay.smartfoxserver.util.scheduling.ITaskHandler)
--- At line: 70
For others trying to do the same thing, you can compare my code with the original 8.18 actionscript code in the documentation.
Here's my whole code:
Code: Select all
from it.gotoandplay.smartfoxserver.util.scheduling import Scheduler
from it.gotoandplay.smartfoxserver.util.scheduling import Task
from it.gotoandplay.smartfoxserver.util.scheduling import ITaskHandler
scheduler = None #null won't work in python.
def init():
global scheduler
scheduler = Scheduler();
task1 = Task( {"name":"have breakfast"} )
handlerObj = {};
handlerObj["count"] = 0
handlerObj["doTask"] = timerTest; #referring to a function below since python can't use inline functions...
##########################
#this is the code where I get the error:
taskHandler = ITaskHandler( handlerObj )
##########################
scheduler.addScheduledTask(task1, 3, false, taskHandler)
and finally outside of init, I made another function called timerTest to correspond with what doTask is pointing to :
Code: Select all
def timerTest(task):
_server.trace("timer test callback called");Any help would be appreciated. If I can just get past this one sticking point then I should be able to finish my project and I will post up a detailed walk through to help others in the future.