accessing top objects/functions within factory.createRequestHandler = function(request) and multiple object calls to .theApp.onInit

25 views
Skip to first unread message

PaulANormanNZ

unread,
Oct 14, 2011, 8:47:27 PM10/14/11
to GLUEscript
Hi,

When you're doing something like ...

var factory = new net.HTTPRequestHandlerFactory();
factory.createRequestHandler = function(request)
{
var handler = new
net.HTTPRequestHandler();
handler.handleRequest =
function(request, response)
{

// doing something at this level

}
glue.server = new net.HTTPServer(factory, new
net.ServerSocket(glueServerSocket), new net.HTTPServerParams());
glue.server.start();

And you are making a desktop type app in the browser (great
advantages) that uses server calls,and you want wxwidgets to appear
from within the type of area shown above, is there a stable way of
using top level functions like:

myWx = require("wx");

I've tried

myWx = glue.require("wx");

And

myWx.messageBox("hello from deep function"); works fine, but does not
come to front of screen.

This works ... but

Is it correct/stable, in strict ECMA I expect it to be.

Also, can there be more than one wx object that calls ...

myWx.theApp.onInit = function(){}

... Per / script?

Or are we limited to one object only per script being able to use
dahDah.theApp.onInit = dahdaH

Specifically I have a switch statement which acts on the server
request information, here is a segment. I have run the contents of the
case statement below as a standalone GLUEscript and it works fine -
changing/removing " response. " as appropriate.

case 'navigate':
//response.contentType="text/plain";
//response.print("List Will be here");
// above response(s) test fine


var wxImagDir = glue.require("wx");

wxImagDir.initAllImageHandlers();

wxImagDir.theApp.onInit = function(){ // none of this seems to work

var simple = new wxImagDir.Frame(null, wxImagDir.Id.ANY, "Choose
Directory");

var panel = new wxImagDir.Panel(simple, wxImagDir.Id.ANY);

var button = new wxImagDir.Button(panel, wxImagDir.Id.ANY,
"Choose Image Directory", { x : 40, y : 50 });
var buttonClose = new wxImagDir.Button(panel, wxImagDir.Id.EXIT, "",
{ x : 290, y : 180 });

var showText = new wxImagDir.StaticText(panel, wxImagDir.Id.ANY, "",
{ x : 20, y : 20 });
showText.wrap = 200;
showText.label = "Please Choose The Directory You Wish to Work
with:";

button.onClicked = function(){
var getDir = new wxImagDir.DirDialog(simple,
"Choose Image Directory",
"",
wxImagDir.DirDialog.DEFAULT_STYLE,
wxImagDir.DefaultPosition); //

getDir.showModal();

glue.getDir = getDir;

simple.close();
}

buttonClose.onClicked = function(){
simple.close();
}

simple.center();
simple.visible = true;
return true;
}

response.contentType="text/plain";
response.print(glue.getDir.path); // as theApp.onInit does not appear
to fire, this: TypeError: glue.getDir is undefined

wxImagDir.messageBox("hello from deep function"); // works fine if
above line REMed out, but does not come to front of screen

break;
Paul

Franky Braem

unread,
Oct 16, 2011, 9:10:11 AM10/16/11
to GLUEscript
I don't think it's a good idea to mix wx code and other multithreaded
code (the server socket code is run in another thread then the main
thread). There's only one theApp variable in a script. onInit is only
called before the wx-application enters the mainloop. So changing this
function has no effect.

Franky

Paul A Norman

unread,
Oct 16, 2011, 6:16:41 PM10/16/11
to glues...@googlegroups.com
Tangling threads ... ok avoid spider's web ..  thanks for that.

Will it be ok to do pipes for command line input in side server functions  the same way or does the same apply?

Paul


--
You received this message because you are subscribed to the Google Groups "GLUEscript" group.
To post to this group, send email to glues...@googlegroups.com.
To unsubscribe from this group, send email to gluescript+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gluescript?hl=en.


Paul A Norman

unread,
Oct 18, 2011, 7:40:01 PM10/18/11
to glues...@googlegroups.com
For now I'll just use the new PHP 5.4.0beta1 for built in  server requirements and GLUEscript by system() calls from there for ui requirements outside the browser.

Paul
Reply all
Reply to author
Forward
0 new messages