The perl code for the beatnik and asylum image servers follows. I could put a $showname variable at the head
of the script and have only that to change for new clones, but so far Red has been happy to edit the root
name each of the three places it occurs. A quick check for access collision, what happens when two viewers
ask for the same slide at almost exactly the same time, shows the webhosting server to be properly buffered,
so not much time is spent re-writting the 'now showing' file. If there is a collision, it doesnt matter, it just
means the 'now showing' file is already being updated by the other viewer. The call to open the slide list does not
have a programmed response for when it fails, and this should be fixed, to just load the @batch with the default, $nows.
We have been falling back on the anfycam.class applet on the client side to call the image server, but will
soon have to make our own, to get the sort of control we want. The version in use for the full resolution asylum
show, before the images were pulled off onto MeoWx, is here . The code in progress has gotten a bit further
than this. The call to 'getSize' has to be put in an exception test that falls back to using the deprecated size field, at
the very least, as some of our viewers have fairly old java versions.
As long as we are getting naked, here is the most recent java thrashing related to the slide show download. java2.
#!\perl\bin\perl
### no no no use LWP::Simple;
$townpath = "./beatnik/"; ##### the archive of slides
$nowsh = "./cgi-bin/beatniksho.txt"; ##### text file with whats showing now
$slist = "./cgi-bin/beatnikseq.txt"; ##### local list of files to show
$nows = "mvc-002f.jpg"; ##### default if nothing found
$interval = 10; ##### default seconds between slides
$resetTime = 14400; ##### reset the show if idle this long
##### how long has it been showing
$isnow = time;
@fstat=stat($nowsh);
$was = @fstat[9];
##### get the info on what is showing now
if (open(NOW, "<$nowsh")) {
@norg=
#!\perl\bin\perl
use LWP::Simple;
$townpath = "./images/asylum/"; ##### the archive on webbittown.net
$nowsh = "./cgi-bin/asylumshowing.txt"; ##### text file here with more info on whats showing
$slist = "./asylum/batch1.txt"; ##### local list of files on MeoWx to show, with pause times
$fastest = 10;
##### how long has it been showing
$isnow = time;
@fstat=stat($nowsh);
$was = @fstat[9];
##### get the info on what is showing now
if (open(NOW, "<$nowsh")) {
@norg=
/** A 'webcam' applet, that repeatedly downloads a designated file and displays it
Due to caching annoyances, each new version advances in name. This one is camb.
It was deployed on webbittown.net for a while, but it is not compatible with
Symantec Netscape JVM 1.1.2 on apple, due to the getSize calls.
Anfycam -does- work on the apple I could test. Anfycam does not look super on
decompiling with javap, so I do not know yet what the exact problem is.
*/
import java.applet.*;
import java.awt.*;
public class camb extends Applet implements Runnable {
Image bi;
Image offscreenImage;
Graphics offscreenGraphics;
MediaTracker mt;
int rwidth;
int rheight;
String slideFile;
String backFile;
public void init(){
String wid = getParameter("width");
String hig = getParameter("height");
slideFile = getParameter("slide");
backFile = getParameter("bkgnd");
mt = new MediaTracker (this);
bi=getImage( getDocumentBase(), backFile );
rwidth = Integer.parseInt(wid);
rheight = Integer.parseInt(hig);
offscreenImage = createImage( getSize().width, getSize().height);
offscreenGraphics = offscreenImage.getGraphics();
}
public void paint(Graphics g) {
g.setColor(getBackground());
g.fillRect(0,0,getSize().width,getSize().height);
g.drawImage(bi,0,0,rwidth,rheight,this);
}
public void run() {
while (true) {
try{Thread.sleep(20000);}
catch(InterruptedException ie) { }
bi.flush();
bi=getImage(getDocumentBase(),slideFile);
mt.addImage(bi,1);
try { mt.waitForID(1);}
catch (InterruptedException ie) {return;}
repaint();
}
}
public void update(Graphics g) {
paint(offscreenGraphics);
g.drawImage(offscreenImage,0,0,this);
}
Thread t;
public void start() {
t = new Thread(this);
t.start();
}
public void stop() {
t.stop();
t = null;
}
}
/** A 'webcam' applet, that repeatedly downloads a designated file and displays it
Due to caching annoyances, each new version advances in name. This one is akm,
derived from cjm
Some old apple browsers do not have getSize, so I have to test for the error and use the deprecated
method if needed:
Symantec Java! ByteCode Compiler Copyright (C) 1996-97 Symantec
Corporation
# Applet exception: error: java.lang.NoSuchMethodError:
java.awt.Component: method getSize ()Ljava/awt/Dimension; not found
java.lang.NoSuchMethodError: java.awt.Component: method getSize
()Ljava/awt/Dimension; not found
at
at netscape.applet.DerivedAppletFrame.run(Compiled Code)
at java.lang.Thread.run(Compiled Code)
*/
import java.applet.*;
import java.awt.*;
import java.net.*;
import java.io.*;
import java.util.*;
public class akm extends Applet implements Runnable {
Image bi;
Image offscreenImage;
Graphics offscreenGraphics;
MediaTracker mt;
Dimension apDim;
String slideFile;
String backFile;
String seqFile;
String imagePath;
String message;
Vector seqOfNames;
Vector PicBuf;
int textat;
public void init(){
slideFile = getParameter("slide");
backFile = getParameter("bkgnd");
imagePath = "http://www.webbittown.com/wml/asylum/asylum/";
seqFile = "http://www.webbittown.com/wml/asylum/asylum/batch1.txt";
try {
apDim = getSize();
}
catch ( NoSuchMethodError e ) {
apDim = size();
}
bi=getImage( getDocumentBase(), backFile );
repaint();
mt = new MediaTracker (this);
seqOfNames = new Vector();
PicBuf = new Vector();
textat = 0;
offscreenImage = createImage( apDim.width, apDim.height);
offscreenGraphics = offscreenImage.getGraphics();
repaint();
}
public void paint(Graphics g) {
g.setColor(getBackground());
g.fillRect(0,0,apDim.width, apDim.height);
if ( bi != null ) {
g.drawImage( bi ,0,0,apDim.width,apDim.height,this);
}
}
public void run() {
if ( t == Thread.currentThread() ) {
while ( true ) {
if ( textat < PicBuf.size() ) {
bi = (Image)PicBuf.elementAt(textat);
textat = (textat < PicBuf.size()-1)? ++textat : 0;
mt.addImage(bi,1);
try { mt.waitForID(1);}
catch (InterruptedException ie) {return;}
repaint();
try{Thread.sleep(100);}
catch(InterruptedException ie) { }
}
}
} //if thread t
if ( u == Thread.currentThread() ) {
try {
URL u = new URL( seqFile );
DataInputStream dis = new DataInputStream( u.openConnection().getInputStream() );
String s;
while ( (s=dis.readLine())!=null ) {
seqOfNames.addElement(s);
bi = getImage(getDocumentBase(),imagePath + s );
mt.addImage(bi,1);
try { mt.waitForID(1);}
catch (InterruptedException ie) {return;}
PicBuf.addElement( bi );
}
}
catch (Exception e) {
e.printStackTrace();
}
} //if thread u
}
public void update(Graphics g) {
paint(offscreenGraphics);
g.drawImage(offscreenImage,0,0,this);
}
Thread t;
Thread u;
public void start() {
t = new Thread(this);
u = new Thread(this);
t.start();
u.start();
}
public void stop() {
// deprecated?? t.stop();
t = null;
u = null;
}
}