summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--swat/esptest/qooxdoo.esp5
-rw-r--r--swat/scripting/client/call.js47
-rw-r--r--swat/scripting/general_calls.esp26
3 files changed, 66 insertions, 12 deletions
diff --git a/swat/esptest/qooxdoo.esp b/swat/esptest/qooxdoo.esp
index dbdb4ddc7a..76d3236fc9 100644
--- a/swat/esptest/qooxdoo.esp
+++ b/swat/esptest/qooxdoo.esp
@@ -53,8 +53,7 @@
}
function start_call() {
- server_call('remote.esp', 'printf', null,
- "Starting calls ... (stopit=%d)\\n", stopit);
+ srv_printf("Starting calls ... (stopit=%d)\\n", stopit);
stopit = 0;
shared.counter = 0;
shared.start_time = 0;
@@ -62,7 +61,7 @@
};
function stop_call() {
- server_call('remote.esp', 'printf', null, "Stopping calls\\n");
+ srv_printf("Stopping calls\\n");
stopit = 1;
};
diff --git a/swat/scripting/client/call.js b/swat/scripting/client/call.js
index d1671ef70f..3af6a5a876 100644
--- a/swat/scripting/client/call.js
+++ b/swat/scripting/client/call.js
@@ -40,7 +40,7 @@ function __http_object() {
/*
usage:
- server_call(url, func, callback, ...);
+ vserver_call(url, func, callback, args);
'func' is a function name to call on the server
any additional arguments are passed to func() on the server
@@ -48,17 +48,17 @@ function __http_object() {
The callback() function is called with the returned
object. 'callback' may be null.
*/
-function server_call(url, func, callback) {
+function vserver_call(url, func, callback, args) {
+ var args2 = new Object();
+ args2.length = args.length;
+ var i;
+ for (i=0;i<args.length;i++) {
+ args2[i] = args[i];
+ }
var req = __http_object();
req.open("POST", url, true);
req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
- var args = new Object();
- var i;
- for (i=3;i<arguments.length;i++) {
- args[i-3] = arguments[i];
- }
- args.length = i-3;
- req.send("func=" + func + "&args=" + encodeObject(args));
+ req.send("func=" + func + "&args=" + encodeObject(args2));
req.onreadystatechange = function() {
if (4 == req.readyState && callback != null) {
var o = decodeObject(req.responseText);
@@ -67,3 +67,32 @@ function server_call(url, func, callback) {
}
}
+
+/*
+ usage:
+
+ server_call(url, func, callback, ...);
+
+ 'func' is a function name to call on the server
+ any additional arguments are passed to func() on the server
+
+ The callback() function is called with the returned
+ object. 'callback' may be null.
+*/
+function server_call(url, func, callback) {
+ var args = new Object();
+ var i;
+ for (i=3;i<arguments.length;i++) {
+ args[i-3] = arguments[i];
+ }
+ args.length = i-3;
+ vserver_call(url, func, callback, args);
+}
+
+
+/*
+ call printf on the server
+*/
+function srv_printf() {
+ vserver_call('/scripting/general_calls.esp', 'srv_printf', null, arguments);
+}
diff --git a/swat/scripting/general_calls.esp b/swat/scripting/general_calls.esp
new file mode 100644
index 0000000000..3a78ff6bbb
--- /dev/null
+++ b/swat/scripting/general_calls.esp
@@ -0,0 +1,26 @@
+<%
+/*
+ used for general purpose calls
+*/
+libinclude("server_call.js");
+
+/* register a call for clients to make */
+var call = servCallObj();
+
+/*
+ a remote printf, for displaying stuff on smbd stdout
+*/
+function srv_printf()
+{
+ println("in srv_printf");
+ var s = string_init();
+ print(s.vsprintf(arguments));
+ return undefined;
+}
+
+/* add some basic calls */
+call.add('srv_printf', srv_printf);
+
+/* run the function that was asked for */
+call.run();
+%>