Thank you for your answer.
= Intro =
Before you read this long message, can you answer this question: Is it
possible to code the worker in Java?
If it is possible, forget the JSNI, PITA, etc.
If not, I want to do a JSNI and JSNI callback to my Java methods, like
Jason's PITA (pre-GWT 1.5)
= Body =
Still, I am having some trouble.
I tried a simpler example:
private static final String WORKER_JS_SRC = ""
+ "function workerInit() {"
+ " google.gears.workerPool.onmessage =
function(messageString,
srcWorkerId){"
+ " google.gears.workerPool.sendMessage('DONE',
srcWorkerId);"
+ " };" + "}" + "return workerInit;";
public void start() {
// create a new worker thread to start generating primes
final int workerId = workerPool.createWorker(WORKER_JS_SRC);
panel.add(new Label(String.valueOf(workerId)));
workerPool.sendMessage("Test", workerId);
}
Cool it works. Now I am sure that the signature is still
"function(messageString, srcWorkerId)".
But maybe the number of arguments is variable in JavaScript.
The "function(a, b, event)" may be compatible with
"function(messageString, srcWorkerId)", where "a" and "b" are
equivalent respectively to "messageString", "srcWorkerId" and "event"
is an object ("event.body" and "event.sender"), which comes from the
new Gears Worker implementation.
As I am not sure, I keep "function(messageString, srcWorkerId)".
I tried, in the same way the JSNI method.
private native String worker() /*-{
function workerInit() {
google.gears.workerPool.onmessage =
function(messageString,
srcWorkerId){
google.gears.workerPool.sendMessage('DONE',
srcWorkerId);
};
}
return workerInit;";
}-*/;
It doesn't work.
In the Chandel's message, the code is:
private native String getSudokuGenerationFunction() /*-{
function workerMessageHandler(msg, sender) {
try {
//computePrimes computes all primes for the number in
msg
var primes = computePrimes(msg);
gearsWorkerPool.sendMessage(primes, sender);
} catch(e) {
//take corrective action
}
}
var workerCode = String(workerMessageHandler) + '
gearsWorkerPool.onmessage = workerMessageHandler';
return workerCode;
}-*/;
So I tried something alike:
private native String worker() /*-{
function workerMessageHandler(msg, sender) {
google.gears.workerPool.sendMessage('done', sender);
}
var workerCode = String(workerMessageHandler) + '
gearsWorkerPool.onmessage = workerMessageHandler';
return workerCode;
}-*/;
Again, it doesn't work.
It is hard to explain, but I tried many ways to do the JSNI method
explained in
http://groups.google.com/group/Google-Web-Toolkit/msg/4aec89cb494e56ce,
and I was not able to get this thing running.
In fact, I tried the very interesting work of Jason, the PITA.
But as his work is based on the old implementation pre-GWT 1.5 gwt-
google-api, I changed his code with GWT 1.5 gwt-gears, and it doesn't
work.
This is why I want to be sure that the JSNI method works, as the PITA
uses also this method.
Also I read that it is not possible to do a JSNI callback from the
worker.
Is it always true now?
= =
I am not a JavaScript coder, but more a Java developer.
I am very interested in Gears to do applications with GWT (RIA), like
Eclipse does with its RCP.
I developed some GWT applications with OSGi+Jetty.
As Chrome has Gears embedded, I thought it was possible to do the same
thing without Jetty and OSGi.
The main problem I have, it is the development of the worker, which
lacks in Java support.
Again, as Chandel said:
*4*) Write it in Java code and have it "just work" as you would expect
without any setup tricks (currently planned for a future release of
gwt-google-apis)
Is it always planned or have you something that works with Java?
You have done great work with GWT, Gears and Chrome (multi-threading).
I have, as many developers for a week, a great interest in your
technologies, because I think it is now possible to develop better,
online and offline, web applications.
If it is possible to code the worker in Java, it would be great.
Thanks.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---