aboutsummaryrefslogtreecommitdiff
path: root/websocket/src/main/java/fi/iki/elonen/samples/echo/EchoSocketSample.java
blob: d22968c0f3dae068dc948c9ecc0af6ca7dcff624 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package fi.iki.elonen.samples.echo;

import java.io.IOException;

import fi.iki.elonen.NanoWebSocketServer;

public class EchoSocketSample {
    public static void main(String[] args) throws IOException {
        final boolean debugMode = args.length >= 2 && args[1].toLowerCase().equals("-d");
        NanoWebSocketServer ws = new DebugWebSocketServer(args.length > 0 ? Integer.parseInt(args[0]) : 9090, debugMode);
        ws.start();
        System.out.println("Server started, hit Enter to stop.\n");
        try {
            System.in.read();
        } catch (IOException ignored) {
        }
        ws.stop();
        System.out.println("Server stopped.\n");
    }

}