[Encore] A couple of questions re WEB display.
Daniel Jung
jung at uib.no
Sun Nov 12 21:06:56 MST 2006
Kevin Jepson wrote:
> 1) Why does having a custom _html or look_self verb mean that the room's WEB
> display is not shown without an explicit look?
Don't understand the question. Please rephrase.
> 2) What is the trigger for updating the WEB display? Where in the system is
> the code that decides when the display should be updated.
The trigger is a HTTP request for the HTML page. If you open another
browser window (as long as you are logged in and your cookie is valid),
you may ask this external browser window to show you
http://yourserver:7000/62 - and you are viewing object #62.
Now, instead of having to ask individually each time an object should be
shown, this information can be send from the server to the user's
computer. Since a web server is just a web server and thus an idiot who
does not do things of its own except serving pages, it cannot do things
on the user's computer. But if you are connected with a persistant
machine-to-machine connection, like telnet, the telnet server can send
an information to the user's computer.
In enCore, we use java (a java applet) to build and maintain a telnet
connection while we are connected to the platform. This way, everytime
we want one frame in the user's screen to change, a single line is send
from the server to the applet. The applet uses the java built-in
"showDocument" method (=routine/verb) which changes the contents of a
given frame.
This string currently looks like
<http://yourserver:7000/62 web_frame>.
Whenever the applet encounters a string like this, it triggers the page
"#62 on the platform" to be shown in "web_frame" of the current frameset
the applet is running in.
So in order to force a page on another participant's screen, you have to
make the server send exactly this string.
The :look_self() and :display_user_location() and :move_via_web() etc.
verbs do that.
This has changed somewhat in version 5, where ALL instances of the
string producing are channeled through the $string_utils and enhanced
with a personal magic string to be detected and approved of by the
applet in order to prevent malicious code to be run on a user machine.
The basic idea however is the same.
Does this answer your question?
> 3) This one is pretty cool but I'd like to know WHY it works.
> If I include the following code block in a custom _html verb the resultant
> html page has the whole enCore header, css and display properties
> automatically.
> ====
> title = this:titlec();
> html = {};
> html = HYPERLINK "mailto:\{@html"{@html, tostr(" <link rel='shortcut icon'
> href='http://seafarer.no-ip.biz:8000/seafarer/moo/images/system/favicon.ico'
> /> <title>", title, "(Seafarer)</title>")};
This is invalid code. No way this compiles. I guess the email client
messed things up.
> title = tostr("<div class=\"title\">", this:titlec(), "</div>");
> htmlHYPERLINK "mailto:html=\{@html,title"={@html,title};
(1) Your verb is putting together HTML background code.
(2) The $httpd (web demon) :get() verb is parsing this background code.
If it doesn't encounter a <html> or another valid xml-command for
opening a page, it thinks that this page needs a correct wrapping. It
puts then a correct head and title and everything around the text it is
fed with. ($encore_web_utils do that with the :make_head(), :make_body()
and :make_page() verbs.)
Now, since your code DOES provide some things that should be in the
head, but does NOT provide a valid head, an enCore head is produced, and
your code is put after the head as a body. This is NOT valid code, and
shouldn't work, so I wonder why it works, but apparently, the browsers
are sloppy enough to make that pass through. So I guess it does "for the
life of you" work in spite of being invalid.
In order to make thing correctly (valid), you should produce the
complete head and the complete html/xhtml shell in your verb. E.g.,
html = {"<html>"};
html = {@html, "<head>"};
html = {@html, "<title>bla bla</title>"};
html = {@html, "<link rel='shortcut icon' href='blabla'>"};
html = {@html, "</head>"};
html = {@html, "<body>"};
... your body code here ...
html = {@html, "</body>"};
html = {@html, "</html>"};
return html;
or, even smarter (pseudo code ahead!):
title = $encore_web_utils:title("bla bla");
icon = $encore_web_utils:link("shortcut icon", "bla bla");
head = $encore_web_utils:make_head({title, icon});
body = ... your body code here ...
body = $encore_web_utils:make_body(body);
page = $encore_web_utils:make_page({head, body});
return page;
(some of that is v5 style)
- Daniel
More information about the Encore
mailing list