LSL communications
Asked Answered
K

5

5

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.

Kisor answered 19/9, 2008 at 16:25 Comment(0)
B
5

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.

Bliss answered 19/9, 2008 at 18:23 Comment(0)
I
4

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.
Inflexion answered 4/2, 2009 at 18:0 Comment(0)
I
2

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

Intumescence answered 10/4, 2009 at 23:59 Comment(0)
P
2

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.

Partizan answered 19/6, 2009 at 22:6 Comment(0)
D
0

As Ilya said, REST and LSL-HTTP would be the way to go.

The new implementation of JSON within the Linden Scripting Language should help with that. You might want to start with reading the Json usage in LSL page on the official wiki.

Duron answered 3/6, 2013 at 10:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.