All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
com.google.scrollview.ScrollView Class Reference

Static Public Member Functions

static void addMessage (SVEvent e)
 
static String receiveMessage () throws IOException
 
static void exit ()
 
static void main (String[] args)
 

Static Public Attributes

static int SERVER_PORT = 8461
 
static BufferedReader in
 
static float polylineXCoords []
 
static float polylineYCoords []
 
static int polylineSize
 
static int polylineScanned
 

Detailed Description

The ScrollView class is the main class which gets started from the command line. It sets up LUA and handles the network processing.

Author
wanke.nosp@m.@goo.nosp@m.gle.c.nosp@m.om

Definition at line 32 of file ScrollView.java.

Member Function Documentation

static void com.google.scrollview.ScrollView.addMessage ( SVEvent  e)
inlinestatic

Add a new message to the outgoing queue

Definition at line 60 of file ScrollView.java.

60  {
61  if (debugViewNetworkTraffic) {
62  System.out.println("(S->c) " + e.toString());
63  }
64  String str = e.toString();
65  // Send the whole thing as UTF8.
66  try {
67  byte [] utf8 = str.getBytes("UTF8");
68  out.write(utf8, 0, utf8.length);
69  } catch (java.io.UnsupportedEncodingException ex) {
70  System.out.println("Oops... can't encode to UTF8... Exiting");
71  System.exit(0);
72  }
73  out.println();
74  // Flush the output and check for errors.
75  boolean error = out.checkError();
76  if (error) {
77  System.out.println("Connection error. Quitting ScrollView Server...");
78  System.exit(0);
79  }
80  }
static void com.google.scrollview.ScrollView.exit ( )
inlinestatic

Called from the client to make the server exit.

Definition at line 358 of file ScrollView.java.

358  {
359  System.exit(0);
360  }
static void com.google.scrollview.ScrollView.main ( String[]  args)
inlinestatic

The main function. Sets up LUA and the server connection and then calls the IOLoop.

Definition at line 366 of file ScrollView.java.

366  {
367  if (args.length > 0) {
368  SERVER_PORT = Integer.parseInt(args[0]);
369  }
370  windows = new ArrayList<SVWindow>(100);
371  intPattern = Pattern.compile("[0-9-][0-9]*");
372  floatPattern = Pattern.compile("[0-9-][0-9]*\\.[0-9]*");
373 
374  try {
375  // Open a socket to listen on.
376  ServerSocket serverSocket = new ServerSocket(SERVER_PORT);
377  System.out.println("Socket started on port " + SERVER_PORT);
378 
379  // Wait (blocking) for an incoming connection
380  socket = serverSocket.accept();
381  System.out.println("Client connected");
382 
383  // Setup the streams
384  out = new PrintStream(socket.getOutputStream(), true);
385  in =
386  new BufferedReader(new InputStreamReader(socket.getInputStream(),
387  "UTF8"));
388  } catch (IOException e) {
389  // Something went wrong and we were unable to set up a connection. This is
390  // pretty
391  // much a fatal error.
392  // Note: The server does not get restarted automatically if this happens.
393  e.printStackTrace();
394  System.exit(1);
395  }
396 
397  // Enter the main program loop.
398  IOLoop();
399  }
static BufferedReader in
Definition: ScrollView.java:44
static String com.google.scrollview.ScrollView.receiveMessage ( ) throws IOException
inlinestatic

Read one message from client (assuming there are any).

Definition at line 83 of file ScrollView.java.

83  {
84  return in.readLine();
85  }
static BufferedReader in
Definition: ScrollView.java:44

Member Data Documentation

BufferedReader com.google.scrollview.ScrollView.in
static

Definition at line 44 of file ScrollView.java.

int com.google.scrollview.ScrollView.polylineScanned
static

Definition at line 48 of file ScrollView.java.

int com.google.scrollview.ScrollView.polylineSize
static

Definition at line 47 of file ScrollView.java.

float com.google.scrollview.ScrollView.polylineXCoords[]
static

Definition at line 45 of file ScrollView.java.

float com.google.scrollview.ScrollView.polylineYCoords[]
static

Definition at line 46 of file ScrollView.java.

int com.google.scrollview.ScrollView.SERVER_PORT = 8461
static

The port our server listens at.

Definition at line 35 of file ScrollView.java.


The documentation for this class was generated from the following file: