More UPnP Programming
Events
-
Devices contain services
-
Services have state variables
-
When a state variable changes state, it can generate events
-
Control points can subscribe to all event changes in
a service
-
When a control point subscribes, it is sent a lease time. It must
renew before this lease time expires
-
A control point subscribes in CyberGarage using the method
ControlPoint.subscribe(Service)
-
An event is generated by setting the value of a state variable
StateVariable.setValue()
-
The files are available
here
Timer
Interface for different implementations of timers, matches the methods
defined for the timer service
Ticker Timer
Another implementation that runs a "ticker" in a thread to update the
time. This timer is invalid until something else sets its time
Clock device
Listener
This will listen to events and print them
Compile and run
Remote UI
-
The "local" UI for a clock is the frame that shows it ticking and maybe
flashing
-
Each clock is aware of the other clocks and makes programmatic
calls on it, but does not display the other clocks, only itself
-
The validity program makes programmatic calls on the clocks, but does not
display any of them
-
If a control point displays a UI for a clock then it has two choices
-
display a general UI for a clock, no matter what type
-
display a UI customised for each clock (e.g. different colours,
different layout, banner ads, etc)
-
If a control point needs to display a clock's UI, then it must get it
from the clock
UPnP remote UI
-
UPnP standardises on an HTML document for a device's remote UI
-
The device XML description may contain a URL for the UI
document
-
It is unspecified what the HTML document can do. HTMl form? Javascript?
-
It is unspecified how the browser then interacts with the device
Cybergarage remote UI
-
A device runs an HTTP server (to handle SOAP requests)
-
This is done by a method
Device.httpRequestRecieved() (note
the spelling mistake)
-
Your device (which inherits from
Device) can override this
method by looking for HTTP requests relating to UI,and passing all
others to its super-class
-
On the client side, the
JEditorPane can display HTML pages
loaded through a URL
-
It will respond to mouse clicks over a hyperlink if
isEditable()
is set to false, and then calls a HyperLinkListener
-
The method
hyperLinkUpdate() can load or reload a URL,
but the code is a bit messy due to a caching bug in JEditorPane
-
I haven't figured out yet how to monitor a Submit button in a page -
perhaps you need to get the DOM and attach listeners in there
-
The files are available
here
Remote UI ClockDevice
Remote UI client
Compile and run
-
Compile all files using
javac with classpath set to include
-
src directory
-
clink132a.jar
-
xercesImpl.jar
-
xml-apis.jar
-
Run the files using
java with classpath set to
-
classes directory
-
clink132a.jar
-
xercesImpl.jar
-
xml-apis.jar
-
The run commands are
java clock.TickerClock
java clock.ComputerClock
java client.UI
Jan Newmarch (http://jan.newmarch.name)
jan@newmarch.name
Last modified: Wed May 26 20:55:11 EST 2004
Copyright ©Jan Newmarch