Skip to content

Commit b2673f7

Browse files
committed
Make ChatServer example listen on a non-privileged port (8887).
Also made ChatServer listen for both draft 75 and 76 clients via Draft.AUTO, instead of only draft 75 with Draft.DRAFT75.
1 parent 2e4fc75 commit b2673f7

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

example/ChatClient.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
public class ChatClient extends WebSocketClient {
2121
private final JTextArea ta;
2222

23-
public ChatClient(URI uri, JTextArea ta,Draft draft) {
24-
super(uri,Draft.DRAFT75);
23+
public ChatClient(URI uri, JTextArea ta, Draft draft) {
24+
super(uri, draft);
2525
this.ta = ta;
2626
}
2727

@@ -56,7 +56,7 @@ public Frame() {
5656
c.setLayout(layout);
5757

5858
uriField = new JTextField();
59-
uriField.setText("ws://localhost");
59+
uriField.setText("ws://localhost:8887");
6060
c.add(uriField);
6161

6262
connect = new JButton("Connect");
@@ -109,7 +109,7 @@ public void actionPerformed(ActionEvent e) {
109109
connect.setEnabled(false);
110110
uriField.setEditable(false);
111111
try {
112-
cc = new ChatClient(new URI(uriField.getText()), area,Draft.DRAFT76);
112+
cc = new ChatClient(new URI(uriField.getText()), area, Draft.DRAFT76);
113113
cc.connect();
114114
} catch (URISyntaxException ex) {
115115
area.append(uriField.getText() + " is not a valid WebSocket URI\n");

example/ChatServer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
public class ChatServer extends WebSocketServer {
1010

1111
public ChatServer(int port) {
12-
super(port, Draft.DRAFT75);
12+
super(port, Draft.AUTO);
1313
}
1414

1515
public void onClientOpen(WebSocket conn) {
@@ -41,7 +41,7 @@ public void onClientMessage(WebSocket conn, String message) {
4141
}
4242

4343
public static void main(String[] args) {
44-
int port = 88;
44+
int port = 8887;
4545
try {
4646
port = Integer.parseInt(args[0]);
4747
} catch(Exception ex) {}

example/chat.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
</script>
6464
</head>
6565
<body>
66-
<form id="uriForm"><input type="text" id="uri" value="ws://localhost" style="width:200px;"> <input type="submit" id="connect" value="Connect"><input type="button" id="disconnect" value="Disconnect" disabled="disabled"></form><br>
66+
<form id="uriForm"><input type="text" id="uri" value="ws://localhost:8887" style="width:200px;"> <input type="submit" id="connect" value="Connect"><input type="button" id="disconnect" value="Disconnect" disabled="disabled"></form><br>
6767
<form id="sendForm"><input type="text" id="textField" value="" style="width:200px;"> <input type="submit" value="Send"></form><br>
6868
<form><textarea id="log" rows="30" cols="100" style="font-family:monospace; color:red;"></textarea></form><br>
6969
</body>

0 commit comments

Comments
 (0)