File tree Expand file tree Collapse file tree
src/net/tootallnate/websocket Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import java .io .BufferedReader ;
12import java .io .IOException ;
3+ import java .io .InputStreamReader ;
24
35import net .tootallnate .websocket .WebSocket ;
46import net .tootallnate .websocket .WebSocketServer ;
@@ -43,13 +45,20 @@ public void onError(Throwable ex) {
4345 ex .printStackTrace ();
4446 }
4547
46- public static void main (String [] args ) {
48+ public static void main (String [] args ) throws IOException {
49+ WebSocket .DEBUG = true ;
4750 int port = 8887 ;
4851 try {
4952 port = Integer .parseInt (args [0 ]);
5053 } catch (Exception ex ) {}
5154 ChatServer s = new ChatServer (port );
5255 s .start ();
5356 System .out .println ("ChatServer started on port: " + s .getPort ());
57+
58+ BufferedReader sysin = new BufferedReader ( new InputStreamReader ( System .in ) );
59+ while (true ){
60+ String in = sysin .readLine ();
61+ s .sendToAll ( in );
62+ }
5463 }
5564}
Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ public enum Role{
6161 */
6262 public static final byte END_OF_FRAME = (byte )0xFF ;
6363
64- public static final boolean DEBUG = false ;
64+ public static /* final*/ boolean DEBUG = false ; //must be final in the future in order to take advantage of VM optimization
6565
6666
6767 // INSTANCE PROPERTIES /////////////////////////////////////////////////////
@@ -415,5 +415,9 @@ private void open(){
415415 public int getPort (){
416416 return socketChannel .socket ().getLocalPort ();
417417 }
418-
418+
419+ @ Override
420+ public String toString ( ) {
421+ return super .toString (); //its nice to be able to set breakpoints here
422+ }
419423}
You can’t perform that action at this time.
0 commit comments