Second Life integration

26 Oct 2009

Hey everyone,

In school I am studying "Digital Virtual Environments" and for my final project I did not want to create some gay machinima video or some goole earth tour, I want to create some sort of portal from the real world do the digital virtual world.

I have seen the example about second life in the cookbook and I just have one problem. The PHP code at the end of the page seems to return a syntax error  "Parse error: syntax error, unexpected '{' in /home/myrtahos/public_html/mbed.php on line 12"

I do not have much experience with php so I was wondering if anyone could spot the error, or help me fix this.

Thanks for all your help.

<?php
    $channel = $_REQUEST["channel"]; // e.g. e3de9c3d-0dae-5125-b655-94d0bf05134a
    $data = $_REQUEST["data"];

    $xmldata = "<?xml version=\"1.0\"?><methodCall><methodName>llRemoteData</methodName><params><param><value><struct><member><name>Channel</name><value>\
<string>".$channel."</string></value></member><member><name>IntValue</name><value><int>0</int></value></member><member><name>StringValue</name><value>\
<string>".$data."</string></value></member></struct></value></param></params></methodCall>";
        
    $host = "xmlrpc.secondlife.com";
    $path = "/cgi-bin/xmlrpc.cgi";

    if(!($fp = fsockopen($host, 80, $errno, $errstr, 30)) {
        print("Could not connect");
        exit();
    }
    fputs($fp, "POST $path HTTP/1.1\r\n");
    fputs($fp, "Host: $host\r\n");
    fputs($fp, "Content-type: text/xml\r\n");
    fputs($fp, "Content-length: " . strlen($xmldata) . "\r\n");
    fputs($fp, "Connection: close\r\n\r\n");
    fputs($fp, $xmldata);
    echo "<pre>";
    while (!feof($fp)) {
        echo fgets($fp,1024);
    }
    echo "</pre>";
    fclose($fp);
?>

26 Oct 2009

You're missing a closing bracket on line 12.

    if(!($fp = fsockopen($host, 80, $errno, $errstr, 30)) {

should be:

    if(!($fp = fsockopen($host, 80, $errno, $errstr, 30))) {

Cheers,

Mike.

26 Oct 2009 . Edited: 26 Oct 2009

You sir have saved me hours. I will fix this on the cookbook too for others.

Thank you very much!

26 Oct 2009

Sorry just another quick issue,

I have set up and object and script at http://www.myrtahosting.com/mbed.php?data=green&channel=f9448834-22e8-b6f2-08d5-042a5bfb4ba9

To send the data to the second life servers, everything is working fine when I used safari to browse the URL, but im not sure why my mbed will not go to the URL is this the POST or GET command, I have tried both. Anyone have any ideas what I am doing wrong?

 

the line I am using is:

http.get("http://www.myrtahosting.com/mbed.php?data=green&channel=f9448834-22e8-b6f2-08d5-042a5bfb4ba9", result);

27 Oct 2009

Hi Vlad,

Thanks for the hint. I've just had a quick look at it and figured out that it is the same behaviour as with the HTTPServer. Looks like a timeout comes much too early and the HTTPClient gets trapped forever or returns with an error. I've updated the HTTPClient implementation to wait longer between the polls, which works fine for me (from here). Please have a look and try to confirm that it's working for you as well.

If you use the new trunk version of the HTTPClient: http://mbed.org/projects/cookbook/svn/EMAC/lwip/trunk

The problem should be gone.

Cheers

Rolf

 

27 Oct 2009

Hey Rolf,

No problem, I have updated my library and re-compiled the project and success. The mbed is sending out the request and finishes the job. The problem is that it only works about 1/3rd of the time. I dont know if the timeout is still comming in early but I have to reset my mbed a few times before it sends it out. Any ideas?

29 Oct 2009

Hi Vlad,

I was thinking about a different timeout model. At the moment the timeout occurs after a fixed number of tries. But now with 2 different mbeds one at 60MHz and one at 100MHz it might be not a good idea. Especially if I consider that I just tuned the timeouts to work for me.

I've modified the httpclient to have a fix 1 minute timeout. This might work better.

I'm not sure if this will solve your problem but at least it is a try. To use this import the lwip core from: http://mbed.org/projects/cookbook/svn/EMAC/lwip/trunk/Core and then the HTTPClient from the zip: httpclient_timed.zip.

Let me know if this helps. It might be worthy to change the HTTPServer as well to see if it can help Nick as well.

Thanks

Rolf

29 Oct 2009

Thanks Rolf I will try this today and let you know if it works any better.

Its a tricky balance between too long and too short as a timeout.

29 Oct 2009

I have updated the libraries and there seems to be no difference. I am starting to feel as tho the server is the one responsible because it seems it always works on the first try and then not again for a little while.

 

02 Nov 2009

Hi Vlad,

I'm not convinced that the server causes the problems, it might be an unlucky combination but I've seen this problem before. It seems to be a problem with our lwip setting or lwip itself. Nicks server problem sounds very similar.

I was browsing the lwip change logs and noticed that they had some similar problems. So I've spent some time on the weekend to port over a newer version of lwip.

Unfortunately the new lwip core is breaking some HTTPServer functions, so I have to spend more time to investigate that. But I'm working on it. I'm not fully convinced that this will solve this problem, but everything looks a little bit more stable.

Cheers Rolf

 

02 Nov 2009

Thanks for all your hard work Rolf. I have tried to upload my file to a different server and it seems the same problem occurs. Im excited for your new lwip port just let me know when your are finished and I will give it a go.

 

Thanks,

Vlad