views:

431

answers:

5
+3  Q: 

LSL communications

Years ago I created a programming collaboratory in Diversity University MOO -- a room written in MOOcode that used TCP/IP to communicate with a perl server back at my campus to compile and execute C, Perl, Bash and other programs and return results to the MOO collaboratory -- all for demonstrating programming languages in a MOO teaching environment. The application is usually a romp in five or six languages and fun to play with. Now I'd like to do the same thing in SecondLife using LSL. The only suggestion I've gotten so far from that crowd is to use a WWW request, presumeably constructing an http POST message to a CGI process. I never cared much for html forms so I'd rather use TCP/IP or some other communications protocol. Has anyone tried this who'd care to provide a few hints? There are several good LSL demo sites in SecondLife but I'd like to demo other compiler and script languages, maybe even PowerShell. Dick S.

+3  A: 

REST is now in fashion for web services. There is no real reason to get down to TCP/IP layer for something which from your description does not require super performance or response times. LSL HTTP support is quite good so you should not have any problems.

Of course it is not ideal to get the output of your programs back in real-time - for that you would need to open http connection on the server and constantly write to the body of the page (while the client would read that). But even with going back and forth between the server and the client you should get moderately good experience.

Ilya Kochetov
+3  A: 

LSL's external communication options are limited to three specific options. The official LSL wiki provides more detailed information on each option.

  • Raw HTTP: requests must be initiated by LSL script
  • XmlHTTP: requests must be initiated by external service
  • Email: full two-way communication, but with enforced sleep timers.
Mike
+2  A: 

I would tend to agree with Ilya.

The Best you might be able to pull if you want the script to be very responsive is to have your server side code call back to the object once the server is made aware of it using the XML-RPC.

The main wiki for Second Life is pretty good for sample code, etc. XML-RPC

Giggy
+2  A: 

LSL's llHTTPRequest function and corresponding http_response event are definitely your best bet.

Contrary to the assumption posed in your question, using http does not necessitate using "html forms". The POST (or PUT) payload can contain data organized however you want. A REST interface is a good way to do the kind of machine-to-machine http communication we're talking about. One advantage of REST over html or xml is that REST can be much less verbose. This is important when you start approaching LSL's 2048 character limit on http responses.

Though LSL has two other methods of communicating with the rest of the internet (email and xml-rpc), their use in LSL scripts is highly discouraged these days. Both of these systems (as currently implemented in Second Life) rely on centralized servers to route messages to their destinations. This doesn't scale well. These servers are under ever-increasing load as Second Life grows. llHTTPRequest on the other hand runs entirely on the simulator running your script, which means you don't have to worry about missing messages because of overloaded central servers.

Finally, there will soon be a new feature added to LSL allowing any script to act as an http server (see http://wiki.secondlife.com/wiki/LSL_http_server). It's currently (as of June 2009) deployed on the beta grid, but should be on the main grid with the next major update. With this addition, many of the current LSL-to-web programs that regularly poll a web server for updated data will instead be able to have updates pushed to them when they happen.

Brent
A: 

And things continue to change - the V2.0 viewer includes much improved facilities for displaying flash and web pages on prims.

Anni