Commit | Line | Data |
---|---|---|
55b4f29b KL |
1 | /* |
2 | * Jexer - Java Text User Interface | |
3 | * | |
4 | * License: LGPLv3 or later | |
5 | * | |
6 | * This module is licensed under the GNU Lesser General Public License | |
7 | * Version 3. Please see the file "COPYING" in this directory for more | |
8 | * information about the GNU Lesser General Public License Version 3. | |
9 | * | |
10 | * Copyright (C) 2015 Kevin Lamonte | |
11 | * | |
12 | * This program is free software; you can redistribute it and/or | |
13 | * modify it under the terms of the GNU Lesser General Public License | |
14 | * as published by the Free Software Foundation; either version 3 of | |
15 | * the License, or (at your option) any later version. | |
16 | * | |
17 | * This program is distributed in the hope that it will be useful, but | |
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
20 | * General Public License for more details. | |
21 | * | |
22 | * You should have received a copy of the GNU Lesser General Public | |
23 | * License along with this program; if not, see | |
24 | * http://www.gnu.org/licenses/, or write to the Free Software | |
25 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | |
26 | * 02110-1301 USA | |
27 | * | |
28 | * @author Kevin Lamonte [kevin.lamonte@gmail.com] | |
29 | * @version 1 | |
30 | */ | |
31 | package jexer.demos; | |
32 | ||
33 | import java.net.*; | |
005ec497 | 34 | import jexer.net.*; |
55b4f29b KL |
35 | |
36 | /** | |
37 | * This class is the main driver for a simple demonstration of Jexer's | |
38 | * capabilities. Rather than run locally, it serves a Jexer UI over a TCP | |
39 | * port. | |
40 | */ | |
41 | public class Demo2 { | |
42 | ||
43 | /** | |
44 | * Main entry point. | |
45 | * | |
46 | * @param args Command line arguments | |
47 | */ | |
48 | public static void main(final String [] args) { | |
49 | try { | |
50 | if (args.length == 0) { | |
51 | System.err.printf("USAGE: java -cp jexer.jar jexer.demos.Demo2 port\n"); | |
52 | return; | |
53 | } | |
54 | ||
55 | int port = Integer.parseInt(args[0]); | |
005ec497 | 56 | ServerSocket server = new TelnetServerSocket(port); |
55b4f29b KL |
57 | while (true) { |
58 | Socket socket = server.accept(); | |
59 | System.out.printf("New connection: %s\n", socket); | |
60 | DemoApplication app = new DemoApplication(socket.getInputStream(), | |
61 | socket.getOutputStream()); | |
62 | (new Thread(app)).start(); | |
63 | } | |
64 | } catch (Exception e) { | |
65 | e.printStackTrace(); | |
66 | } | |
67 | } | |
68 | ||
69 | } |