Created
October 20, 2009 02:54
-
-
Save wez/213953 to your computer and use it in GitHub Desktop.
playing with workers in titanium
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = Titanium.Filesystem; | |
var api = Titanium.API; | |
api.print("worker starting\n"); | |
var path = fs.getResourcesDirectory() + fs.getSeparator() + 'worker.php'; | |
api.print("PHP code is at " + path + "\n"); | |
if (false) { | |
onmessage = function(event) { | |
api.print("worker got an event\n"); | |
var j = Titanium.JSON.stringify(event.message); | |
api.print("event contents are " + j + "\n"); | |
var res; | |
try { | |
res = Titanium.PHP.evaluate( | |
'text/php', 'workerbits', | |
"include('" + path + "');\n", | |
event.message); | |
} catch (err) { | |
api.print("Error while evaluating " + err + "\n"); | |
} | |
api.print("After calling the php worker\n"); | |
api.print("res is " + res + "\n"); | |
}; | |
} else { | |
var res; | |
try { | |
res = Titanium.PHP.evaluate( | |
'text/php', 'workerbits', | |
"include('" + path + "');\n", | |
new Object()); | |
} catch (err) { | |
api.print("Error while evaluating " + err + "\n"); | |
} | |
api.print("After calling the php worker\n"); | |
api.print("res is " + res + "\n"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment