Class WSServer

java.lang.Object
fi.iki.elonen.NanoHTTPD
fi.iki.elonen.NanoWSD
me.autobot.lib.server.WSServer

public class WSServer extends fi.iki.elonen.NanoWSD
A websocket server for the robot.
  • Nested Class Summary

    Nested classes/interfaces inherited from class fi.iki.elonen.NanoWSD

    fi.iki.elonen.NanoWSD.State, fi.iki.elonen.NanoWSD.WebSocket, fi.iki.elonen.NanoWSD.WebSocketException, fi.iki.elonen.NanoWSD.WebSocketFrame

    Nested classes/interfaces inherited from class fi.iki.elonen.NanoHTTPD

    fi.iki.elonen.NanoHTTPD.AsyncRunner, fi.iki.elonen.NanoHTTPD.ClientHandler, fi.iki.elonen.NanoHTTPD.ContentType, 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.HTTPSession, 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 inherited from class fi.iki.elonen.NanoWSD

    HEADER_CONNECTION, HEADER_CONNECTION_VALUE, HEADER_UPGRADE, HEADER_UPGRADE_VALUE, HEADER_WEBSOCKET_ACCEPT, HEADER_WEBSOCKET_KEY, HEADER_WEBSOCKET_PROTOCOL, HEADER_WEBSOCKET_VERSION, HEADER_WEBSOCKET_VERSION_VALUE

    Fields inherited from class fi.iki.elonen.NanoHTTPD

    asyncRunner, MIME_HTML, MIME_PLAINTEXT, MIME_TYPES, SOCKET_READ_TIMEOUT
  • Constructor Summary

    Constructors
    Constructor
    Description
    WSServer(int port)
    Starts the WSServer on the given port.
  • Method Summary

    Modifier and Type
    Method
    Description
    static WSServer
    Gets the instance of the WSServer.
    static void
    main(String[] args)
    The main method of the WSServer, only used for testing the server.
    protected fi.iki.elonen.NanoWSD.WebSocket
    openWebSocket(fi.iki.elonen.NanoHTTPD.IHTTPSession handshake)
    Opens a new WebSocket connection.
    static void
    Starts the WSServer on port 8080.

    Methods inherited from class fi.iki.elonen.NanoWSD

    isWebsocketRequested, makeAcceptKey, serve, serveHttp, useGzipWhenAccepted

    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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • WSServer

      public WSServer(int port) throws IOException
      Starts the WSServer on the given port.
      Parameters:
      port - The port to start the server on.
      Throws:
      IOException - If the server cannot be started.
  • Method Details

    • main

      public static void main(String[] args)
      The main method of the WSServer, only used for testing the server.
      Parameters:
      args - The arguments of the main method.
    • wsstart

      public static void wsstart()
      Starts the WSServer on port 8080.
    • getInstance

      public static WSServer getInstance()
      Gets the instance of the WSServer.
      Returns:
      The instance of the WSServer.
    • openWebSocket

      protected fi.iki.elonen.NanoWSD.WebSocket openWebSocket(fi.iki.elonen.NanoHTTPD.IHTTPSession handshake)
      Opens a new WebSocket connection.
      Specified by:
      openWebSocket in class fi.iki.elonen.NanoWSD
      Parameters:
      handshake - The handshake of the WebSocket connection.
      Returns:
      The WebSocket connection.