diff --git a/centrifuge/src/main/java/io/github/centrifugal/centrifuge/ConfigurationError.java b/centrifuge/src/main/java/io/github/centrifugal/centrifuge/ConfigurationError.java index 0d5ab55..a5526d5 100644 --- a/centrifuge/src/main/java/io/github/centrifugal/centrifuge/ConfigurationError.java +++ b/centrifuge/src/main/java/io/github/centrifugal/centrifuge/ConfigurationError.java @@ -4,6 +4,7 @@ public class ConfigurationError extends Throwable { private final Throwable error; ConfigurationError(Throwable error) { + super(error); this.error = error; } diff --git a/centrifuge/src/main/java/io/github/centrifugal/centrifuge/Options.java b/centrifuge/src/main/java/io/github/centrifugal/centrifuge/Options.java index 1d2e474..039824b 100644 --- a/centrifuge/src/main/java/io/github/centrifugal/centrifuge/Options.java +++ b/centrifuge/src/main/java/io/github/centrifugal/centrifuge/Options.java @@ -11,32 +11,55 @@ public String getToken() { return token; } + /** + * Set connection token. If your tokens expire and you want SDK to automatically + * refresh tokens then set ConnectionTokenGetter (see below). + */ public void setToken(String token) { this.token = token; } - /* Connection token. This is a token you have to receive from your application backend. */ + /** + * Connection token. This is a token you have to receive from your application backend. + */ private String token = ""; - public String getName() { - return name; + public ConnectionTokenGetter getTokenGetter() { + return tokenGetter; } - public void setName(String name) { - this.name = name; + /** + * Set a method to extract new connection token upon expiration. + */ + public void setTokenGetter(ConnectionTokenGetter tokenGetter) { + this.tokenGetter = tokenGetter; } - /** + private ConnectionTokenGetter tokenGetter; + + public String getName() { + return name; + } + + /** * Set client name - name of this client. This should not be unique per client – it * identifies client application name actually, so name should have a limited * number of possible values. By default this client uses "java" as a name. */ + public void setName(String name) { + this.name = name; + } + private String name = "java"; public String getVersion() { return version; } + /** + * Set client version - version of application. This may be used for observability + * on the server (for example in analytics). + */ public void setVersion(String version) { this.version = version; } @@ -47,13 +70,19 @@ public byte[] getData() { return data; } + /** + * Set custom connection data. This data will be delivered to server in Connect command. + * For Centrifugo this may be useful in case of using connect proxy. + */ public void setData(byte[] data) { this.data = data; } - /* Connect data to send to a server inside Connect command. */ private byte[] data; + /** + * Set custom headers for WebSocket Upgrade request. + */ public void setHeaders(Map headers) { this.headers = headers; } @@ -69,14 +98,22 @@ public int getTimeout() { return timeout; } + /** + * Set custom timeout for requests in milliseconds. By default, 5000 is used. + */ public void setTimeout(int timeout) { this.timeout = timeout; } + private int timeout = 5000; + public int getMinReconnectDelay() { return minReconnectDelay; } + /** + * Set minimal time before reconnect attempt in milliseconds. By default, 500 is used. + */ public void setMinReconnectDelay(int minReconnectDelay) { this.minReconnectDelay = minReconnectDelay; } @@ -87,24 +124,31 @@ public int getMaxReconnectDelay() { return maxReconnectDelay; } + /** + * Set max time between reconnect attempts in milliseconds. By default, 20000 is used. + */ public void setMaxReconnectDelay(int maxReconnectDelay) { this.maxReconnectDelay = maxReconnectDelay; } private int maxReconnectDelay = 20000; - private int timeout = 5000; - public int getMaxServerPingDelay() { return maxServerPingDelay; } + /** + * Set max time of ping delay from server in milliseconds. By default, 10000 is used. + */ public void setMaxServerPingDelay(int maxServerPingDelay) { this.maxServerPingDelay = maxServerPingDelay; } private int maxServerPingDelay = 10000; + /** + * Set proxy to use. + */ public void setProxy(Proxy proxy) { this.proxy = proxy; } @@ -118,6 +162,9 @@ public Proxy getProxy() { private String proxyLogin; private String proxyPassword; + /** + * Set proxy credentials. + */ public void setProxyCredentials(String login, String password) { this.proxyLogin = login; this.proxyPassword = password; @@ -131,19 +178,13 @@ public String getProxyPassword() { return proxyPassword; } - public ConnectionTokenGetter getTokenGetter() { - return tokenGetter; - } - - public void setTokenGetter(ConnectionTokenGetter tokenGetter) { - this.tokenGetter = tokenGetter; - } - - private ConnectionTokenGetter tokenGetter; - public Dns getDns() { return this.dns; } + + /** + * Set custom DNS resolver.. + */ public void setDns(Dns dns) { this.dns = dns; } diff --git a/centrifuge/src/main/java/io/github/centrifugal/centrifuge/PresenceResult.java b/centrifuge/src/main/java/io/github/centrifugal/centrifuge/PresenceResult.java index 291bf08..e204ff0 100644 --- a/centrifuge/src/main/java/io/github/centrifugal/centrifuge/PresenceResult.java +++ b/centrifuge/src/main/java/io/github/centrifugal/centrifuge/PresenceResult.java @@ -11,5 +11,5 @@ public Map getClients() { return clients; } - private Map clients; + private final Map clients; } diff --git a/centrifuge/src/main/java/io/github/centrifugal/centrifuge/RefreshError.java b/centrifuge/src/main/java/io/github/centrifugal/centrifuge/RefreshError.java index 8d8ae40..115eda7 100644 --- a/centrifuge/src/main/java/io/github/centrifugal/centrifuge/RefreshError.java +++ b/centrifuge/src/main/java/io/github/centrifugal/centrifuge/RefreshError.java @@ -1,15 +1,14 @@ package io.github.centrifugal.centrifuge; -import javax.annotation.Nullable; - public class RefreshError extends Throwable { private final Throwable error; - RefreshError(@Nullable Throwable error) { + RefreshError(Throwable error) { + super(error); this.error = error; } - public @Nullable Throwable getError() { + public Throwable getError() { return error; } } diff --git a/centrifuge/src/main/java/io/github/centrifugal/centrifuge/ResultCallback.java b/centrifuge/src/main/java/io/github/centrifugal/centrifuge/ResultCallback.java index 9b68458..9b8fb60 100644 --- a/centrifuge/src/main/java/io/github/centrifugal/centrifuge/ResultCallback.java +++ b/centrifuge/src/main/java/io/github/centrifugal/centrifuge/ResultCallback.java @@ -3,5 +3,8 @@ import javax.annotation.Nullable; public interface ResultCallback { + /** + * onDone will be called when the operation completed. Either Throwable or T will be not null. + */ void onDone(@Nullable Throwable e, @Nullable T result); } diff --git a/centrifuge/src/main/java/io/github/centrifugal/centrifuge/SubscriptionErrorEvent.java b/centrifuge/src/main/java/io/github/centrifugal/centrifuge/SubscriptionErrorEvent.java index b2346fa..d263fcd 100644 --- a/centrifuge/src/main/java/io/github/centrifugal/centrifuge/SubscriptionErrorEvent.java +++ b/centrifuge/src/main/java/io/github/centrifugal/centrifuge/SubscriptionErrorEvent.java @@ -1,9 +1,10 @@ package io.github.centrifugal.centrifuge; -public class SubscriptionErrorEvent { +public class SubscriptionErrorEvent extends Throwable { private final Throwable error; SubscriptionErrorEvent(Throwable t) { + super(t); this.error = t; } diff --git a/centrifuge/src/main/java/io/github/centrifugal/centrifuge/SubscriptionRefreshError.java b/centrifuge/src/main/java/io/github/centrifugal/centrifuge/SubscriptionRefreshError.java index c1a9a64..bf3055c 100644 --- a/centrifuge/src/main/java/io/github/centrifugal/centrifuge/SubscriptionRefreshError.java +++ b/centrifuge/src/main/java/io/github/centrifugal/centrifuge/SubscriptionRefreshError.java @@ -4,6 +4,7 @@ public class SubscriptionRefreshError extends Throwable { private final Throwable error; SubscriptionRefreshError(Throwable error) { + super(error); this.error = error; } diff --git a/centrifuge/src/main/java/io/github/centrifugal/centrifuge/SubscriptionSubscribeError.java b/centrifuge/src/main/java/io/github/centrifugal/centrifuge/SubscriptionSubscribeError.java index cd424ad..8c19968 100644 --- a/centrifuge/src/main/java/io/github/centrifugal/centrifuge/SubscriptionSubscribeError.java +++ b/centrifuge/src/main/java/io/github/centrifugal/centrifuge/SubscriptionSubscribeError.java @@ -4,6 +4,7 @@ public class SubscriptionSubscribeError extends Throwable { private final Throwable error; SubscriptionSubscribeError(Throwable error) { + super(error); this.error = error; } diff --git a/centrifuge/src/main/java/io/github/centrifugal/centrifuge/SubscriptionTokenError.java b/centrifuge/src/main/java/io/github/centrifugal/centrifuge/SubscriptionTokenError.java index 6686cad..965d51b 100644 --- a/centrifuge/src/main/java/io/github/centrifugal/centrifuge/SubscriptionTokenError.java +++ b/centrifuge/src/main/java/io/github/centrifugal/centrifuge/SubscriptionTokenError.java @@ -4,6 +4,7 @@ public class SubscriptionTokenError extends Throwable { private final Throwable error; SubscriptionTokenError(Throwable error) { + super(error); this.error = error; } diff --git a/centrifuge/src/main/java/io/github/centrifugal/centrifuge/SubscriptionTokenEvent.java b/centrifuge/src/main/java/io/github/centrifugal/centrifuge/SubscriptionTokenEvent.java index 93cf671..42b44a3 100644 --- a/centrifuge/src/main/java/io/github/centrifugal/centrifuge/SubscriptionTokenEvent.java +++ b/centrifuge/src/main/java/io/github/centrifugal/centrifuge/SubscriptionTokenEvent.java @@ -1,7 +1,7 @@ package io.github.centrifugal.centrifuge; public class SubscriptionTokenEvent { - private String channel; + final private String channel; public SubscriptionTokenEvent(String channel) { this.channel = channel; @@ -10,8 +10,4 @@ public SubscriptionTokenEvent(String channel) { public String getChannel() { return channel; } - - void setChannel(String channel) { - this.channel = channel; - } } diff --git a/centrifuge/src/main/java/io/github/centrifugal/centrifuge/TokenError.java b/centrifuge/src/main/java/io/github/centrifugal/centrifuge/TokenError.java index 300709a..68148eb 100644 --- a/centrifuge/src/main/java/io/github/centrifugal/centrifuge/TokenError.java +++ b/centrifuge/src/main/java/io/github/centrifugal/centrifuge/TokenError.java @@ -4,6 +4,7 @@ public class TokenError extends Throwable { private final Throwable error; TokenError(Throwable error) { + super(error); this.error = error; } diff --git a/centrifuge/src/main/java/io/github/centrifugal/centrifuge/UnclassifiedError.java b/centrifuge/src/main/java/io/github/centrifugal/centrifuge/UnclassifiedError.java index ae4158a..a9b6ec2 100644 --- a/centrifuge/src/main/java/io/github/centrifugal/centrifuge/UnclassifiedError.java +++ b/centrifuge/src/main/java/io/github/centrifugal/centrifuge/UnclassifiedError.java @@ -4,6 +4,7 @@ public class UnclassifiedError extends Throwable { private final Throwable error; UnclassifiedError(Throwable error) { + super(error); this.error = error; }