Fix incoherence in WebSocket example
Motivation: The logic in the current websocket example is confusing and misleading Modifications: Remove occurrences of "http" and "https" and replace them with "ws" and "wss" Result: The example code is now coherent and is easier to understand for a new user.
This commit is contained in:
parent
ed3d26cf7d
commit
9bcfef0f10
@ -61,13 +61,13 @@ public final class WebSocketClient {
|
|||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
URI uri = new URI(URL);
|
URI uri = new URI(URL);
|
||||||
String scheme = uri.getScheme() == null? "http" : uri.getScheme();
|
String scheme = uri.getScheme() == null? "ws" : uri.getScheme();
|
||||||
final String host = uri.getHost() == null? "127.0.0.1" : uri.getHost();
|
final String host = uri.getHost() == null? "127.0.0.1" : uri.getHost();
|
||||||
final int port;
|
final int port;
|
||||||
if (uri.getPort() == -1) {
|
if (uri.getPort() == -1) {
|
||||||
if ("http".equalsIgnoreCase(scheme)) {
|
if ("ws".equalsIgnoreCase(scheme)) {
|
||||||
port = 80;
|
port = 80;
|
||||||
} else if ("https".equalsIgnoreCase(scheme)) {
|
} else if ("wss".equalsIgnoreCase(scheme)) {
|
||||||
port = 443;
|
port = 443;
|
||||||
} else {
|
} else {
|
||||||
port = -1;
|
port = -1;
|
||||||
|
Loading…
Reference in New Issue
Block a user