public class HttpServer
extends java.lang.Object
implements java.lang.Runnable
HttpConnectionThread
Constructor and Description |
---|
HttpServer(int listenPort,
int refreshRateInSec)
Create a HttpServer instance on the specified listening port.
|
Modifier and Type | Method and Description |
---|---|
int |
getListenPort()
Get the port the mini-webserver is currently listening on.
|
java.util.Iterator<java.lang.String> |
getPathIterator()
Obtain an Iterator across all the GETable pages known to this web server.
|
java.util.Iterator<java.lang.String> |
getPathIterator(java.lang.String method)
Obtain an Iterator across all the pages known to this web server.
|
int |
getRefreshRateInSec()
Get the automatic page refresh rate setting currently sent to browsers.
|
boolean |
registerPage(java.lang.String path,
PathHandler handler)
Register a page handler for a particular path within the website, using the "GET" HTTP method.
|
boolean |
registerPage(java.lang.String method,
java.lang.String path,
PathHandler handler)
Register a page handler for a particular path within the website.
|
void |
run()
Accept incoming HTTP connection requests and spawn a handler thread for each browser connection.
|
void |
setListenPort(int listenPort)
Change the port number that the mini-webserver should listen on.
|
void |
setRefreshRateInSec(int refreshRateInSec)
Set the automatic page refresh rate setting currently sent to browsers.
|
public HttpServer(int listenPort, int refreshRateInSec)
listenPort
- TCP port number to accept incoming HTTP requests onrefreshRateInSec
- refresh interval in seconds for web pages that do auto-refreshingpublic void run()
run
in interface java.lang.Runnable
public int getRefreshRateInSec()
public void setRefreshRateInSec(int refreshRateInSec) throws java.lang.IllegalArgumentException
refreshRateInSec
- page refresh rate in seconds between refreshesjava.lang.IllegalArgumentException
- if specified refresh rate is shorter than 5 secondspublic int getListenPort()
public void setListenPort(int listenPort)
listenPort
- TCP port number for YAAC's internal webserverpublic boolean registerPage(java.lang.String path, PathHandler handler)
path
- String of leading part of URL pathhandler
- PathHandler to generate a response page for the pathpublic boolean registerPage(java.lang.String method, java.lang.String path, PathHandler handler)
method
- String of HTTP method for accessing this pagepath
- String of leading part of URL pathhandler
- PathHandler to generate a response page for the pathpublic java.util.Iterator<java.lang.String> getPathIterator()
public java.util.Iterator<java.lang.String> getPathIterator(java.lang.String method)
method
- String of HTTP method for accessing these pages