Network Monitor - GetURL2File

About Truespace Archives

These pages are a copy of the official truespace forums prior to their removal somewhere around 2011.

They are retained here for archive purposes only.

Network Monitor - GetURL2File // Interactive Artwork

1  |  

Post by early // Sep 13, 2008, 5:55am

early
Total Posts: 46
I want to get this posted, so please excuse the style:


GetURL2File

Fetch a binary file from the internet and write it to a file on disk.


Inputs

URL: The fully qualified url to fetch ie. htpp://somewhere.com/path/image.jpg

Timeout: Time in seconds to allow for _completion_ of HTTP request.

Dest Name: The filename to create or overwrite

Dest Path: the fully-qualified directory to save the file



Outputs

DestName: the fully-qualified name of the saved file (path and filename)

ErrStr: A friendly result string

Status: Normally the HTTP result (200 good, 404 not found, etc.)


Notes

Programmed in VBScript

Uses Microsoft.xmlHTTP

Particularly powerful when pointed at dynamic web content.

Timeout checking is crude - it will always timeout at midnight

Little error checking


Disclaimers

This is experimental and educational code.

During testing, an unresponsive request would lock up trueSpace until I physically disconnected my internet connection.

Additional testing against specific URLs is recommended

It's not a bug, it's a feature



External URLs

Always be considerate with other people's data

There's a reason I haven't hooked my objects to timers.



Improvements needed for GetURL2File:

generalized to handle the other data types (text, html, xml)

Stream support - write data into target object without writing to disk

Better timeout checking

Asynchronous mode

Caching



Sync v. Async

Running the HTTP request asynchonously would be desirable. Unfortunately, I couldn't figure out how to do it in the Rosetta environment. I finally reverted to the synchonous request method, so timeout checking is problematical. Does anyone know if Rosetta supports a 'sleep' function like Wscript.Sleep()?



Applications:

Unlimited.

Post by early // Sep 13, 2008, 6:02am

early
Total Posts: 46
Here is a simple demonstration activity: live webcams in the workspace.


There are thousands of live webcams on the internet. Surf cams, traffic cams, city views, pets, landscapes, personal webcams, and security cameras to mention just a few. Many of them can be tapped with the GetURL2File object.


Simple webcam object.

Contains

GetEnv - to return the user's 'temp' directory

GetURL2File - pointed to an internet webcam, output to a temp file

ImportBitmap (System - Import library) - convert file to bitmap

Cube primitive - bitmap is mapped to the exposed D3D material DiffuseTexure

Sound Player - for some audio feedback when refresh is complete.


The virtual zoo:


Attached are three copies of my simple webcam display object, each pointed to a different URL. They can be updated individually, connected in parallel (as pictured) or in series.


Please do not abuse the webcams.

These webcams were active at the time of posting.


Polar Bears at the San Diego Zoo

http://os8.prod.camzone.com/still?cam=2&i=48:1220938046108:0

Webpage: http://www.sandiegozoo.org/zoo/ex_polar_bear_plunge.html


Penguins at the Sidney Aquarium

http://www.sydneyaquarium.com.au/WebCamImage.aspx?cameraName=pengiun

Webpage: http://www.sydneyaquarium.com.au/Interact/INT022.asp


Shamu at the San Diego Seaworld

http://os9.prod.camzone.com/still?cam=Shamu&i=8:1221025506810:0

Webpage: http://seaworld.com/sitepage.aspx?PageID=375


The polar bears and penguins are uninteresting after dark, Seaworld replays the daytime stream at night.


Here are a few elaborations for the virtual zoo that I'll never have time to make:

Add a model of each animal. Make it selectable. Only selected webcams update quickly. Animals models could be animated and interactive. Tie each location to an animated, lit globe to visually indicate the local solar time. Construct enclosure models to match the webcam view, or something more fanciful. Etc. etc.


When you copy the webcam display object, update the temporary filename in GetURL2File to avoid conflicts.

Post by Norm // Sep 13, 2008, 7:52am

Norm
Total Posts: 862
pic
Very interesting items. It is very cool to see these scenarios opening up in trueSpace!

Post by trueBlue // Sep 13, 2008, 8:07am

trueBlue
Total Posts: 1761
pic
Very nice early! Works perfect! There is no Sleep function for tS76. I notice that you are creating:
Set WshShell = CreateObject("WScript.Shell")

Is it not possible to use Wscript.Sleep()?

Not sure if this is helpful with the Sleep function but here is your object with a Looped/Pause Activity from a boolean toggle button, Dock in the Stack/Panels button, and a Constant material.

Post by early // Sep 13, 2008, 8:27am

early
Total Posts: 46
I can create a 'shell' object, but Wscript is an environment, and Rosetta doesn't use it. So the Wscript.Sleep() function is not accessible. It is the place for Rosetta to provide (or not provide) that functionality. I couldn't find anything in the SDK.


See here for some discussion of the topic (and why it's complicated):

http://blogs.msdn.com/ericlippert/archive/2003/10/07/53155.aspx

Post by Délé // Sep 13, 2008, 9:47am

Délé
Total Posts: 1374
pic
Nice work again early! Again, this is exactly the kind of stuff that I've been wanting to see in tS but never knew how to do myself. It would be very cool if there was a way to have the video play on the cube, but even just grabbing a still shot is very cool.


Thanks for sharing all this cool stuff. It's great to learn from. :) :banana:
Awportals.com is a privately held community resource website dedicated to Active Worlds.
Copyright (c) Mark Randall 2006 - 2024. All Rights Reserved.
Awportals.com   ·   ProLibraries Live   ·   Twitter   ·   LinkedIn