:align "center"
(
(with-output-to-string
(lambda ()
(print "(")
(for-each (lambda (v) (display " ") (write v) (newline))
(hop-autoload-directories))
(display ")")))))
== Server & Client Definitions ==
=== (with-hop (svc v0 ...) [attributes ...] [success] [fail]) ===
with-hop
with-hop
^ arguments ^ type ^ short description ^
| svc | service | the invoked service. |
| v0 | obj | the first argument. |
| ... | ... | ... |
| vn | obj | the nth argument. |
| success | procedure | a procedure of one argument. |
| fail | procedure | a procedure of one argument. |
^ common attributes ^ type ^ short description ^
| :name | string | a remote user name. |
| :password | string | a remote user password. |
| :authorization | string | a remote authorization. |
| :timeout | integer | An optional timeout. |
| :host | string | a remote server name. |
| :port | integer | a remote server port. |
| :abspath | string | the abspath of the service. |
^ client arguments ^ type ^ short description ^
| :anim | procedure or bool | the animation to play while calling. |
~~ The special form ++with-hop++ invokes the server service ++svc++ with
arguments ++v0++, ... On success, it then invokes the
function ++success++ with an object constructed from the service
answer. On failure, it invokes ++failure++.
~~ When a remote ++host++ may be specified, the service is executed on
the remote host. Otherwise, when ++with-hop++ is used from a server
without specifying a remote ++host++, the service is executed
locally.
~~ When used from a client **only**, an animation procedure can be
specified. This procedure of one argument should return a DOM object
that is inserted in the document during a ++with-hop++ call. This
object is automatically hidden when the call completes. If no :anim
attributed is specified, then the value return by ++((with-hop-default-anim))++
is used as animation.
o
~~ The evaluation of the service ++svc++ produce a response. If its
type is not an instance of ::%http-response HOP performs automatic
casts for converting value into instance of ::%http-response. For an
object ++res++, here are the rules that are applied:
* if ++res++ is an XML object (built by a markup), it is automatically
converted into an instance of ::http-response-hop.
* if ++res++ is a pair for which at least one element is an XML object, they
whole result is converted into an instance of ::http-response-hop.
* if ++res++ is a string, it is converted into an instance of
::http-response-string.
* otherwise, ++res++ is converted into an instance of ::http-response-js.
If the response is an instance of ::http-response-js then result it is
interpreted by the client object as a compound object (i.e., a list, a
vector, ...). It it is an instance of the ::http-response-hop or
::http-response-string, it is interpreted as a string.
==== Examples =====
We present various examples that illustrates the different ways to
use the ++with-hop++ form.
===== 1. Sending HTML tree from the server to the client =====
In this first example, an anonymous service send a HTML table to
a client. The return type of the service is an XML element, as
constructed by any markup.
Sending a HTML tree
===== 2. Sending Complex Values =====
In this second example, the server send to the client a instance of a local
class. In this example, the client receives a object that it discriminates
(using the ++obj.x++ and ++obj.y++ expressions) for building a string
that is injected inside the currently visualized HTML tree.
Sending complex values
===== 3. Invoking Services From The Server =====
In this example, we invoke a service directly from the server. The form
++with-hop++ is not protected with a ++~++ client escape marker. It is
then evaluated as all expressions on the server.
Invoking a service from the server
===== 4. Invoking Services From Server To Server =====
In this last example, ++with-hop++ is used to invoke a service from
a remote service. As for the previous example, the form ++with-hop++
is not protected with a ++~++ client escape marker, which means that it
is evaluated on the server. Contrary to the previous address a remote
host is specified using the :host argument.
Invoking a remote service from the server
~~ In this last example, we show how server to server service invocation
may transmit compound values. In the example above, one service sends
an HTML tree. The other one sends a list of strings.
Invoking remote services from the server
===== 5. Specifying a custom animation ====
This example shows how to specify a custom animation when calling
a server service.
WITH-HOP animation
== Client Definitions ==
=== (with-hop-default-anim) ===
with-hop-default-anim
The function ++with-hop-default-anim++ returns the default function for
producing visual animations during ++with-hop++ calls.
=== (with-hop-default-anim-set! procedure) ===
with-hop-default-anim-set!
^ arguments ^ type ^ short description ^
| anim | procedure or bool | a procedure of one argument. |
The function ++with-hop-default-anim-set!++ set! the default function for
producing visual animations during ++with-hop++ calls. It returns the
previous default animation function.
== See also ==
service, define-service, procedure->service, hop-autoload, with-hop