Package com.gears42.iot.webthing
Class WebThingServer
- java.lang.Object
-
- fi.iki.elonen.NanoHTTPD
-
- fi.iki.elonen.router.RouterNanoHTTPD
-
- com.gears42.iot.webthing.WebThingServer
-
public class WebThingServer extends fi.iki.elonen.router.RouterNanoHTTPDServer to represent a Web Thing over HTTP.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classWebThingServer.ActionHandlerHandle a request to /actions/<action_name>.static classWebThingServer.ActionIDHandlerHandle a request to /actions/<action_name>/<action_id>.static classWebThingServer.ActionsHandlerHandle a request to /actions.static classWebThingServer.BaseHandlerBase handler that responds to every request with a 405 Method Not Allowed.static classWebThingServer.ComplianceEventHandlerstatic classWebThingServer.ComplianceHandlerstatic classWebThingServer.EventHandlerHandle a request to /events/<event_name>.static classWebThingServer.EventsHandlerHandle a request to /events.static classWebThingServer.LoginHandlerstatic classWebThingServer.MDMAttributesHandlerHandle a request to /thinginfo/<property>.static classWebThingServer.MultipleThingsA container for multiple things.static classWebThingServer.PropertiesHandlerHandle a request to /properties.static classWebThingServer.PropertyHandlerHandle a request to /properties/<property>.static classWebThingServer.SingleThingA container for a single thing.static classWebThingServer.SSLOptionsClass to hold options required by SSL server.static classWebThingServer.ThingHandlerHandle a request to /.static classWebThingServer.ThingsHandlerHandle a request to / when the server manages multiple things.-
Nested classes/interfaces inherited from class fi.iki.elonen.router.RouterNanoHTTPD
fi.iki.elonen.router.RouterNanoHTTPD.BaseRoutePrioritizer, fi.iki.elonen.router.RouterNanoHTTPD.DefaultHandler, fi.iki.elonen.router.RouterNanoHTTPD.DefaultRoutePrioritizer, fi.iki.elonen.router.RouterNanoHTTPD.DefaultStreamHandler, fi.iki.elonen.router.RouterNanoHTTPD.Error404UriHandler, fi.iki.elonen.router.RouterNanoHTTPD.GeneralHandler, fi.iki.elonen.router.RouterNanoHTTPD.IndexHandler, fi.iki.elonen.router.RouterNanoHTTPD.InsertionOrderRoutePrioritizer, fi.iki.elonen.router.RouterNanoHTTPD.IRoutePrioritizer, fi.iki.elonen.router.RouterNanoHTTPD.NotImplementedHandler, fi.iki.elonen.router.RouterNanoHTTPD.ProvidedPriorityRoutePrioritizer, fi.iki.elonen.router.RouterNanoHTTPD.StaticPageHandler, fi.iki.elonen.router.RouterNanoHTTPD.UriResource, fi.iki.elonen.router.RouterNanoHTTPD.UriResponder, fi.iki.elonen.router.RouterNanoHTTPD.UriRouter
-
Nested classes/interfaces inherited from class fi.iki.elonen.NanoHTTPD
fi.iki.elonen.NanoHTTPD.AsyncRunner, fi.iki.elonen.NanoHTTPD.ClientHandler, fi.iki.elonen.NanoHTTPD.Cookie, fi.iki.elonen.NanoHTTPD.CookieHandler, fi.iki.elonen.NanoHTTPD.DefaultAsyncRunner, fi.iki.elonen.NanoHTTPD.DefaultServerSocketFactory, fi.iki.elonen.NanoHTTPD.DefaultTempFile, fi.iki.elonen.NanoHTTPD.DefaultTempFileManager, fi.iki.elonen.NanoHTTPD.IHTTPSession, fi.iki.elonen.NanoHTTPD.Method, fi.iki.elonen.NanoHTTPD.Response, fi.iki.elonen.NanoHTTPD.ResponseException, fi.iki.elonen.NanoHTTPD.SecureServerSocketFactory, fi.iki.elonen.NanoHTTPD.ServerRunnable, fi.iki.elonen.NanoHTTPD.ServerSocketFactory, fi.iki.elonen.NanoHTTPD.TempFile, fi.iki.elonen.NanoHTTPD.TempFileManager, fi.iki.elonen.NanoHTTPD.TempFileManagerFactory
-
-
Field Summary
Fields Modifier and Type Field Description static android.content.Contextcontext
-
Constructor Summary
Constructors Constructor Description WebThingServer(android.content.Context context, com.gears42.iot.webthing.WebThingServer.ThingsType things)Initialize the WebThingServer on port 80.WebThingServer(android.content.Context context, com.gears42.iot.webthing.WebThingServer.ThingsType things, java.lang.Integer port)Initialize the WebThingServer.WebThingServer(android.content.Context context, com.gears42.iot.webthing.WebThingServer.ThingsType things, java.lang.Integer port, java.lang.String hostname)Initialize the WebThingServer.WebThingServer(android.content.Context context, com.gears42.iot.webthing.WebThingServer.ThingsType things, java.lang.Integer port, java.lang.String hostname, WebThingServer.SSLOptions sslOptions)Initialize the WebThingServer.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static fi.iki.elonen.NanoHTTPD.ResponsecreateSocket(java.util.HashMap<java.lang.String,Thing> things, fi.iki.elonen.NanoHTTPD.IHTTPSession session)static org.json.JSONObjectparseBody(fi.iki.elonen.NanoHTTPD.IHTTPSession session)static java.util.Map<java.lang.String,java.lang.String>splitQuery(java.lang.String url)voidstart(boolean daemon)Start listening for incoming connections.voidstop()Stop listening.-
Methods inherited from class fi.iki.elonen.router.RouterNanoHTTPD
addMappings, addRoute, normalizeUri, removeRoute, serve, setNotFoundHandler, setNotImplementedHandler, setRoutePrioritizer
-
Methods inherited from class fi.iki.elonen.NanoHTTPD
closeAllConnections, getHostname, getListeningPort, getMimeTypeForFile, getServerSocketFactory, getTempFileManagerFactory, isAlive, makeSecure, makeSSLSocketFactory, makeSSLSocketFactory, makeSSLSocketFactory, mimeTypes, newChunkedResponse, newFixedLengthResponse, newFixedLengthResponse, newFixedLengthResponse, serve, setAsyncRunner, setServerSocketFactory, setTempFileManagerFactory, start, start, start, wasStarted
-
-
-
-
Constructor Detail
-
WebThingServer
public WebThingServer(android.content.Context context, com.gears42.iot.webthing.WebThingServer.ThingsType things) throws java.io.IOException, java.lang.NullPointerExceptionInitialize the WebThingServer on port 80.- Parameters:
things- List of Things managed by this server- Throws:
java.io.IOException- If server fails to bind.java.lang.NullPointerException- If something bad happened.
-
WebThingServer
public WebThingServer(android.content.Context context, com.gears42.iot.webthing.WebThingServer.ThingsType things, java.lang.Integer port) throws java.io.IOException, java.lang.NullPointerExceptionInitialize the WebThingServer.- Parameters:
things- List of Things managed by this serverport- Port to listen on- Throws:
java.io.IOException- If server fails to bind.java.lang.NullPointerException- If something bad happened.
-
WebThingServer
public WebThingServer(android.content.Context context, com.gears42.iot.webthing.WebThingServer.ThingsType things, java.lang.Integer port, java.lang.String hostname) throws java.io.IOException, java.lang.NullPointerExceptionInitialize the WebThingServer.- Parameters:
things- List of Things managed by this serverport- Port to listen onhostname- Host name, i.e. mything.com- Throws:
java.io.IOException- If server fails to bind.java.lang.NullPointerException- If something bad happened.
-
WebThingServer
public WebThingServer(android.content.Context context, com.gears42.iot.webthing.WebThingServer.ThingsType things, java.lang.Integer port, java.lang.String hostname, WebThingServer.SSLOptions sslOptions) throws java.io.IOException, java.lang.NullPointerExceptionInitialize the WebThingServer.- Parameters:
things- List of Things managed by this serverport- Port to listen onhostname- Host name, i.e. mything.comsslOptions- SSL options to pass to the NanoHTTPD server- Throws:
java.io.IOException- If server fails to bind.java.lang.NullPointerException- If something bad happened.
-
-
Method Detail
-
start
public void start(boolean daemon) throws java.io.IOExceptionStart listening for incoming connections.- Parameters:
daemon- Whether or not to daemonize the server- Throws:
java.io.IOException- on failure to listen on port
-
stop
public void stop()
Stop listening.- Overrides:
stopin classfi.iki.elonen.NanoHTTPD
-
splitQuery
public static java.util.Map<java.lang.String,java.lang.String> splitQuery(java.lang.String url) throws java.io.UnsupportedEncodingException- Throws:
java.io.UnsupportedEncodingException
-
parseBody
public static org.json.JSONObject parseBody(fi.iki.elonen.NanoHTTPD.IHTTPSession session)
-
createSocket
public static fi.iki.elonen.NanoHTTPD.Response createSocket(java.util.HashMap<java.lang.String,Thing> things, fi.iki.elonen.NanoHTTPD.IHTTPSession session)
-
-