Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

SL <-> Outside World..

CrazeeTastee Gupte
Registered User
Join date: 13 Nov 2005
Posts: 13
03-13-2006 16:32
Okay, I'm trying to get create a system that will be able to send data to and from SecondLife very often (every 1 second or so). The SecondLife scripts will contact a script (probably a Java applet, since I am fairly familiar with Java) that will display this data visually.

I'm a total newbie when it comes to XML-RPC and llEmail, and I've been researching for what seems like forever. Can anybody help me to choose which of these would be the best? Point me in the direction of some code that performs a similar task?

Any help would be very much appreciated. Thanks!
AJ DaSilva
woz ere
Join date: 15 Jun 2005
Posts: 1,993
03-13-2006 16:49
Never used XML-RPC myself, but checking the wiki, sending data over it causes a 3 sec delay. So you're not gonna be able to update as often as you'd like. (Email has an even greater penalty and there's no other ways to communicate outside SL)

Looks like there's some kind of example here: http://secondlife.com/badgeo/wakka.php?wakka=XMLRPC

IIRC you have to send an email from the object that gets caught by the external server in order to start things off.

Hope that helps some, as far as I can tell XMP-RPC is basically just flinging data back and forth in XML - nothing too complex.
Adman Drake
Registered User
Join date: 9 Feb 2006
Posts: 96
03-13-2006 16:59
From: AJ DaSilva
(Email has an even greater penalty and there's no other ways to communicate outside SL)


I believe that SENDING email has a penalty. But receiving email, as far as I can tell, doesn't.
So sending data TO an object shouldn't be that bad.

Sounds like XMLRPC is the way to go, but I haven't done anything with it...

G'luck!

Adman
CrazeeTastee Gupte
Registered User
Join date: 13 Nov 2005
Posts: 13
03-13-2006 17:26
Well, I was thinking about dealing with the delays by having one master script that would tell a series of mailing/data-sending scripts to perform their task. For example, since there is a 20 second delay on llEmail(), I was thinking of having one master script and 20 e-mailing scripts. In the master script, I would probably have a counter specifying which script to send a message to (mail1, mail2, mail3, etc. might be the names of the scripts).

Oh, and does anybody know where I can get a free POP3 that doesn't limit the amount of sent/recieved messages?
AJ DaSilva
woz ere
Join date: 15 Jun 2005
Posts: 1,993
03-13-2006 17:33
I'd say you're still better off using XML-RPC, it should be a more direct route.
CrazeeTastee Gupte
Registered User
Join date: 13 Nov 2005
Posts: 13
03-13-2006 17:36
From: AJ DaSilva
I'd say you're still better off using XML-RPC, it should be a more direct route.


Yeah, from what I've read so far, XML-RPC seems to be less of a hassle. It'd be much easier to eliminate the e-mail factor altogether. Having trouble understanding the whole concept, though. I guess I need to do some more research about how exactly XML-RPC works. A lot of the XML-RPC examples write their client-side scripts in XML (rather then having something like Java do the job for them), which I'm not familiar with, so it's difficult for me to understand. I can't seem to find any good SL->Java examples. :(
AJ DaSilva
woz ere
Join date: 15 Jun 2005
Posts: 1,993
03-13-2006 17:44
The XML you're seeing in the examples is most likely the output of the server scripts, not the scripts themselves. There's not many languages that have you script in XML.

If I understand correctly, all that happens is the LSL script and the PHP/PERL/Whatever script send XML docs back and forth between each other, no big difficult concept.

Wait a while longer and someone in the know will probably poke their head in and explain properly.
CrazeeTastee Gupte
Registered User
Join date: 13 Nov 2005
Posts: 13
03-13-2006 19:00
From: AJ DaSilva
There's not many languages that have you script in XML.


Ehh... I thought XML in itself WAS a language. Am I wrong? Something tells me I missed something.. lol o_o;

From: AJ DaSilva

If I understand correctly, all that happens is the LSL script and the PHP/PERL/Whatever script send XML docs back and forth between each other, no big difficult concept.
.


Yeah, I understand the concept of what's going on, but I don't know how the scripts actually go about sending the documents. The thing that I'm having the most trouble with understanding is that you can't send information from within SecondLife. But I guess you can send information back in a reply? So, instead of using a timer in my LSL script, I guess I'd have to figure out how to use one in my Java applet. Every 3 seconds (script delay time.. curse you, Lindens!! :P), it would send a message requesting data, and the script would reply with everything I needed...? Hm... I guess that would work.
Rodrick Harrington
Registered User
Join date: 9 Jul 2005
Posts: 150
03-13-2006 22:51
From: CrazeeTastee Gupte
Ehh... I thought XML in itself WAS a language. Am I wrong? Something tells me I missed something.. lol o_o;


Language in the form of say a stucture for data, it's interpretation is up the the programs at the endpoints of the data pipe. Think of XML as an all-purpose HTML . . . the browser isn't written in HTML, but rather the data that the browser does something with is.
Dyne Talamasca
Noneuclidean Love Polygon
Join date: 9 Oct 2005
Posts: 436
03-14-2006 02:10
XML is just a way of structuring data in a formal, standard way (such that anything that understands XML has a good chance of at least reading the file, and possibly pulling out what data it can recognize).

This first bit is an email address. OK, done with that.

The next bit is an ISBN number. OK, done with that.

Now we have a list, which contains entries, which might consist of other bits of data such as email addresses or isbn numbers. OK, now that's the end of the list.

This next bit is a paragraph...

And so on.
_____________________
Dyne Talamasca - I hate the word "bling".

Miscellany on MySLShop.com, SLB, and SLEx

Plonk
Leon Ash
Bushveld Resident
Join date: 8 Jan 2006
Posts: 146
An HTML/Javascript XML-RPC example
03-14-2006 05:03
From: CrazeeTastee Gupte
I can't seem to find any good SL->Java examples. :(


Hi CrazeeTastee,

You mention that you'd like to use Java. I created a html form using the javascript example provided in the LSL wiki. This example uses v2 of JSOLait. The wiki uses version 1 and will not work with this example.

The first thing you need to create is the XML-RPC Object in Second Life. Use the LSL Wiki script as it works just fine. This will give you the Channel UUID to use on the HTML form. Please note that this object in SL is effectively the XML-RPC client. It can only respond to commands from the 'program' you are using outside of Second Life. (Yes, it sucks!)

What follows is the 'server' side configuration I ended up with.
1. Download JSOLait v2.0a
2. Create XML-RPC-Test.js
3. Create the HTML form
4. Paste the UUID into the channel on the Form and you are up and running.

1. Download jsolait v2.0a and uncompress it so it is in a sub-folder called jsolait

2. Next copy and paste this javascript into a new file and save it as XML-RPC-Test.js
CODE

// Capture the form information passed from the html page
function send_rpc(form){
var xmlrpc=null;
// Try to import the jsolait xmlrpc module and report error message if fails
try{
var xmlrpc = imprt("xmlrpc");
}catch(e){
var em;
if(e.toTraceString){
em=e.toTraceString();
}else{
em = e.message;
}
form.output.value = em;
return false;
}
// Set the SL XML-RPC Server address & evaluation String from form values
var addr = "http://xmlrpc.secondlife.com/cgi-bin/xmlrpc.cgi";
var evalStr = {"Channel" : form.channel.value, "IntValue" : form.intVal.value, "StringValue" : form.strVal.value};
// Try to contact SL object using the info provided.
// Report XML-RPC response if successful, else report the error.
try{
var service = new xmlrpc.ServiceProxy(addr);
var rslt = service.llRemoteData(evalStr); // Result object
form.output.value = "SL XML-RPC Response:\n\nInteger = " + rslt["IntValue"] + "\n String = " + rslt["StringValue"];
}catch(e){
var em;
if(e.toTraceString){
em=e.toTraceString();
}else{
em = e.message;
}
form.output.value = em;
}
return false;
}


3. Create this html form which calls the javascript which uses the JSOLAIT wrapper to pass the XML-RPC message.
CODE
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8"></meta>
<title>Testing XML-RPC</title>
<script type="text/javascript" src="./jsolait/jsolait.js"></script>
<script type="text/javascript" src="./XML-RPC-Test.js"></script>
</head>
<body>
<h1>Second Life XML-RPC Test</h1>
<form name="xml-rpc-form" action="" >
<center>
<table class="form" width="80%" border="0" cellspacing="0">
<tr>
<td>Channel (UUID)</td>
<td><input name="channel" size="70"></input></td>
</tr>
<tr>
<td>Integer Value</td>
<td><input name="intVal" size="70"></input></td>
</tr>
<tr>
<td>String Value</td>
<td><input name="strVal" size="70"></input></td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="button" name="button" value="Submit" onClick="send_rpc(this.form)"></input>
</td>
</tr>
<tr>
<td colspan="2" align="center"><textarea name="output" rows="7" cols="50" wrap="virtual">When you hit 'Submit' the SL XML-RPC response will be displayed here!</textarea></td>
</tr>
</table>
</center>
</form>
</body>
</html>


4. Open the HTML page, paste in the XML-RPC Channel UUID you've opened in Second Life and away you go :-)

I can't access any of this from work, but feel free to ask questions if any of the above is unclear.

Regards
Leon
Sky Honey
Coder
Join date: 16 May 2005
Posts: 105
03-14-2006 05:23
For anyone reading this thread who would rather use PHP for the server - I highly recommend Gwyneth Llewelyn's essay. That's where I learned XML-RPC and it worked first time.
_____________________
MadamG Zagato
means business
Join date: 17 Sep 2005
Posts: 1,402
03-14-2006 08:22
From: sky Honey
For anyone reading this thread who would rather use PHP for the server - I highly recommend Gwyneth Llewelyn's essay. That's where I learned XML-RPC and it worked first time.


I agree. Not only that, but if you are trying to accomplish something specific...namely a large scale application, you must be patient with yourself. I started on this path about 4 months ago. I gave up after I could not figure XML-RPC out. However after reading more and trying different code here in the forum and in the Wiki, I finally have a grasp on it...at least well enough to do with it what I need accomplished...I even learned PHP in the process becuase I normally use ASP, which lacks 'working' examples.

It's a learning process. You have to remember that you are dealing with at least 3 separate programming languages (LSL, XML-RPC...and your preferred website language (PHP,ASP, JAVA...etc). If you really want to learn it...you will. Just don't give up!

:)
_____________________
Sean Martin
Yesnomaybe.
Join date: 13 Sep 2005
Posts: 584
03-14-2006 23:20
From: CrazeeTastee Gupte
Okay, I'm trying to get create a system that will be able to send data to and from SecondLife very often (every 1 second or so). The SecondLife scripts will contact a script (probably a Java applet, since I am fairly familiar with Java) that will display this data visually.

I'm a total newbie when it comes to XML-RPC and llEmail, and I've been researching for what seems like forever. Can anybody help me to choose which of these would be the best? Point me in the direction of some code that performs a similar task?

Any help would be very much appreciated. Thanks!

I know of a way, er, well someone I know does. But it has to do with those much hated macro programs. Like AutoHotKey. And you need an avitar logged in somewhere at all times as a way to transmit data in real time. It's not the best solution unless that avitar is the product. Like a stronger AI program outside of SL transmiting to the SL client and using the avitar as an NPC or something.
But thats probably not what your looking for.
Other than that I have no idea. :o
_____________________
CrazeeTastee Gupte
Registered User
Join date: 13 Nov 2005
Posts: 13
03-15-2006 16:44
Uh-oh.. I'm stumped. I started writing some of my code, and I was reading the wiki for guidance. Then came the "oh crap" moment. I realized that the string value in an XML-RPC reply could only be up to 255 characters. This is a HUGE issue for me, as I need to be sending pretty big lists of nearby users, their coordinates, etc...

What now? :(
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
03-15-2006 17:18
Break it up, send it as multiple messages. I'll be getting to this same problem soon in one of my projects. Haven't yet fully figured out how to synchronize everything, but it should be doable.
CrazeeTastee Gupte
Registered User
Join date: 13 Nov 2005
Posts: 13
03-17-2006 12:16
From: Ziggy Puff
Break it up, send it as multiple messages. I'll be getting to this same problem soon in one of my projects. Haven't yet fully figured out how to synchronize everything, but it should be doable.


Well, that'd mean it would take about 9 seconds to do what I needed it to do in 3. Trying to get it to send every 3 seconds.. I guess it's not do-able in XML-RPC :(
AJ DaSilva
woz ere
Join date: 15 Jun 2005
Posts: 1,993
03-17-2006 12:21
How about splitting it up, sending it to different scripts with link messages and pumping it through multiple channels?
AJ DaSilva
woz ere
Join date: 15 Jun 2005
Posts: 1,993
03-17-2006 12:22
Actually, what is it you're trying to make? There might be some other work-around...
CrazeeTastee Gupte
Registered User
Join date: 13 Nov 2005
Posts: 13
03-17-2006 15:19
From: AJ DaSilva
Actually, what is it you're trying to make? There might be some other work-around...


Trying to make something that will send information about local people, objects, and recent chat. I want to be able to be in touch with the SL world when I can't be in game. The Java Applet will create a mini-map using dots to represent people/objects. It will send the recent chat as well. Gotta be able to send chat as well.
AJ DaSilva
woz ere
Join date: 15 Jun 2005
Posts: 1,993
03-17-2006 17:23
Right, liiittle bit drunk, so bear with me.

Lets start with sending chat. Not sure how the rules stand sending it if it's not stored anywhere, but generally it's not allowed to store it so I'd be careful there. Perhaps you could have a system for sending messages instead of sending all the chat?

Displaying who's present would be a lot better to do by sending data when someone arrives/leaves the area rather than having a continual stream specifying who's present. Same with the objects, although that could run up against memory limits if there's a lot of objects about. Can't think of a good way to deal with that atm, maybe just objects not owned by you or something?

I think the best thing to do is to work out exactly what it is that's relevant to you before designing the system. Streaming all the data about what's going on in an area is what SL itself does, and trying to replicate it through scripts seems pretty OTT if you ask me. I mean, if someone's shooting a gun nearby do you really need to be notified about every bullet that's rezzed?
Gabriel Tackleberry
Registered User
Join date: 22 Feb 2006
Posts: 23
03-21-2006 23:23
Gwyneth's example states that you should email the channel to yourself.

It seems that the channel is decided when rezzing the object inworld. But I dont see anywhere in the script to reference it. The llOpenRemoteDataChannel(); does not
have a return value.

So in my php script on my webserver, am I just picking a channel at random?

I'm getting the 'problem contacting server' error when I run the php page.
Gabriel Tackleberry
Registered User
Join date: 22 Feb 2006
Posts: 23
03-21-2006 23:39
In Gweneth's example, she states that the channel should be emailed. When touching my inworld object, an email is sent from the remotedata function with 3 other lines in it, which don't appear anywhere in the object script, being object name, region and local position.
where are these lines derived?

secondly, in the php script there is no event type, sender or key parameters.

I'm getting the 'problem contacting RPC server' from my php script on my website.

llRemoteDataReply(channel, channel,online_status, idata); This is the return for an eventtype of remotedatarequest. How does the eventtype get set, and why return channel twice, and simply repeat the integer data and status?

EDITED: I added the faultstring to the website php script. Error is

Connection failed: Couldn't make the connection to xmlrpc.secondlife.com.

the site and port are
xmlrpc.secondlife.com 80


script is unchanged except for the channel and faultstring.

Any help?
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
03-22-2006 04:32
I can't help with it all, but the three lines - as described here are actually four (there's a line feed too) that are automatically appended to the front of the email.
Doctor Pertwee
Registered User
Join date: 22 Dec 2005
Posts: 3
04-28-2006 07:56
From: Leon Ash

var rslt = service.llRemoteData(evalStr); // Result object


service.llRemoteData(evalStr)??


Java has embedded LSL calls???
Proof that the Lindens control everything!
Be afraid! Be very very afraid!

Hmm, have to go check the jsoleit wiki...

Actually, I'm just banging my head over this not working in any browser I am running at the moment :( I dont run the PERL XMLRPC flavors they use in the examples and I thought AHA! A way around it! Alas...

EDIT: OK, dropped shields on the web-browser for my website. I have a working example of XMLRPC. Thank you
_____________________
Eagles soar, but penguins don't get sucked into jet engines!
1 2