Skip to content

Commit ec4c9a2

Browse files
committed
minor modifications to the examples
1 parent f0ce0d9 commit ec4c9a2

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

example/ChatClient.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,7 @@ public void onError( Exception ex ) {
143143
ta.append( uriField.getText() + " is not a valid WebSocket URI\n" );
144144
}
145145
} else if( e.getSource() == close ) {
146-
try {
147-
cc.close();
148-
} catch ( Exception ex ) {
149-
ex.printStackTrace();
150-
}
146+
cc.close();
151147
}
152148
}
153149

example/ChatServer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public ChatServer( InetSocketAddress address ) {
2525
@Override
2626
public void onOpen( WebSocket conn, ClientHandshake handshake ) {
2727
this.sendToAll( "new connection: " + handshake.getResourceDescriptor() );
28-
System.out.println( conn + " entered the room!" );
28+
System.out.println( conn.getRemoteSocketAddress().getAddress().getHostAddress() + " entered the room!" );
2929
}
3030

3131
@Override

example/SSLClientExample.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,12 @@ public static void main( String[] args ) throws Exception {
8484

8585
BufferedReader reader = new BufferedReader( new InputStreamReader( System.in ) );
8686
while ( true ) {
87-
chatclient.send( reader.readLine() );
87+
String line = reader.readLine();
88+
if( line.equals( "close" ) ) {
89+
chatclient.close();
90+
} else {
91+
chatclient.send( line );
92+
}
8893
}
8994

9095
}

0 commit comments

Comments
 (0)