Beruflich Dokumente
Kultur Dokumente
Content is programmable
Virtual Worlds with user-generated content like Second Life® or OpenSimulator provide a fascina=ng new tool for educa=on and simula=on, allowing educators and researchers to explore with a rela=vely simple interface the possibili=es of immersing students (and visitors) in a 3D world with full interac=vity. While
all content and programming can be done from within the free Second Life Viewer applica=on, programming complex applica=ons inside Second Life is oGen challenging, as the built-in programming language has several serious constraints and limita=ons.
A solu=on is to use the func=onality to allow outbound HTTP connec=ons to external servers providing web services, or allow web servers to make inbound HTTP connec=ons to directly manipulate objects inside the virtual world, and leave all the complexi=es of programming and persistent data storage on the
external server. The 3D virtual world thus acts as an “interface” to a more complex applica=on, similar to the role of JavaScript-enabled pages to do client-side rendering, but retrieving data and the complex logic from the web server itself.
This session will show some simple techniques to illustrate how this can be accomplished with a few programming demonstra=ons, live from within the virtual world.
To fully appreciate this session, a reasonable programming experience with any programming language is required; examples will be shown in PHP and Second Life’s proprietary language, Linden Script Language, which is vaguely inspired on JavaScript.
Why the need to use
external servers?
Address memory and performance limitations
Persistent storage
NOAA — Weather being displayed over a map. Visitors can see things move!
Election results — as they come in, selected parts of the map show results
Location of ships and submarines: data on servers is polled and presented visually in 3D
The basics
Linden Scripting Language is event driven
Function call
llHTTPRequest() to call
external server HTTP
GET/
POST Validate request, do
what is requested, and
send back status
-8
TF
nU
ly i
rep
http_reponse triggered
with status
Visually... inbound
Second Life LSL Script Web server
Central Servers
Register external URL
llRequestURL()
quest
Randomly generate valid URL re
URL and return it to
running script Gen
erated
URL http_request triggered
with method ==
URL_REQUEST_GRAN
TED
Select pre-generated
T URL for the object and
OS
T/P make a HTTP GET/
• http_request GE est POST
triggered with method T TP q u
H re
== POST or GET with
• Process request HTT
• Trigger response to P sta
web server with and tus cod
text e
llHTTPResponse()
Process result
To recap...
Sending data out of Second Life is easy: make a
request from the script to the external web server,
get a reply. So long as all is under 2 KB it works!
LSL code has to deal with timeouts and hitting limits (anti-
spam measures to deal with too many requests)