Package fi.iki.elonen
Class NanoWSD
java.lang.Object
fi.iki.elonen.NanoHTTPD
fi.iki.elonen.NanoWSD
- Direct Known Subclasses:
DebugWebSocketServer
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
static class
static class
static class
Nested classes/interfaces inherited from class fi.iki.elonen.NanoHTTPD
NanoHTTPD.AsyncRunner, NanoHTTPD.ClientHandler, NanoHTTPD.ContentType, NanoHTTPD.Cookie, NanoHTTPD.CookieHandler, NanoHTTPD.DefaultAsyncRunner, NanoHTTPD.DefaultServerSocketFactory, NanoHTTPD.DefaultTempFile, NanoHTTPD.DefaultTempFileManager, NanoHTTPD.HTTPSession, NanoHTTPD.IHTTPSession, NanoHTTPD.Method, NanoHTTPD.Response, NanoHTTPD.ResponseException, NanoHTTPD.SecureServerSocketFactory, NanoHTTPD.ServerRunnable, NanoHTTPD.ServerSocketFactory, NanoHTTPD.TempFile, NanoHTTPD.TempFileManager, NanoHTTPD.TempFileManagerFactory
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final char[]
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
private static final Logger
logger to log to.private static final String
Fields inherited from class fi.iki.elonen.NanoHTTPD
asyncRunner, MIME_HTML, MIME_PLAINTEXT, MIME_TYPES, SOCKET_READ_TIMEOUT
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static String
encodeBase64
(byte[] buf) Translates the specified byte array into Base64 string.private boolean
isWebSocketConnectionHeader
(Map<String, String> headers) protected boolean
static String
makeAcceptKey
(String key) protected abstract NanoWSD.WebSocket
openWebSocket
(NanoHTTPD.IHTTPSession handshake) serve
(NanoHTTPD.IHTTPSession session) Override this to customize the server.protected NanoHTTPD.Response
serveHttp
(NanoHTTPD.IHTTPSession session) protected boolean
not all websockets implementations accept gzip compression.Methods inherited from class fi.iki.elonen.NanoHTTPD
closeAllConnections, createClientHandler, createServerRunnable, decodeParameters, decodeParameters, decodePercent, getHostname, getListeningPort, getMimeTypeForFile, getServerSocketFactory, getTempFileManagerFactory, isAlive, makeSecure, makeSSLSocketFactory, makeSSLSocketFactory, makeSSLSocketFactory, mimeTypes, newChunkedResponse, newFixedLengthResponse, newFixedLengthResponse, newFixedLengthResponse, serve, setAsyncRunner, setServerSocketFactory, setTempFileManagerFactory, start, start, start, stop, wasStarted
-
Field Details
-
LOG
logger to log to. -
HEADER_UPGRADE
- See Also:
-
HEADER_UPGRADE_VALUE
- See Also:
-
HEADER_CONNECTION
- See Also:
-
HEADER_CONNECTION_VALUE
- See Also:
-
HEADER_WEBSOCKET_VERSION
- See Also:
-
HEADER_WEBSOCKET_VERSION_VALUE
- See Also:
-
HEADER_WEBSOCKET_KEY
- See Also:
-
HEADER_WEBSOCKET_ACCEPT
- See Also:
-
HEADER_WEBSOCKET_PROTOCOL
- See Also:
-
WEBSOCKET_KEY_MAGIC
- See Also:
-
ALPHABET
private static final char[] ALPHABET
-
-
Constructor Details
-
NanoWSD
public NanoWSD(int port) -
NanoWSD
-
-
Method Details
-
encodeBase64
Translates the specified byte array into Base64 string.Android has android.util.Base64, sun has sun.misc.Base64Encoder, Java 8 hast java.util.Base64, I have this from stackoverflow: http://stackoverflow.com/a/4265472
- Parameters:
buf
- the byte array (not null)- Returns:
- the translated Base64 string (not null)
-
makeAcceptKey
- Throws:
NoSuchAlgorithmException
-
isWebSocketConnectionHeader
-
isWebsocketRequested
-
openWebSocket
-
serve
Description copied from class:NanoHTTPD
Override this to customize the server. (By default, this returns a 404 "Not Found" plain text error response.) -
serveHttp
-
useGzipWhenAccepted
not all websockets implementations accept gzip compression.- Overrides:
useGzipWhenAccepted
in classNanoHTTPD
- Returns:
- true if the gzip compression should be used if the client accespts it. Default this option is on for text content and off for everything. Override this for custom semantics.
-