Skip to content

Commit

Permalink
Merge pull request #30 from LiveTex/auth_update
Browse files Browse the repository at this point in the history
Implemented AuthData with both visitor and custom tokens.
  • Loading branch information
maxxx authored May 19, 2023
2 parents 2823cf4 + 211bfd9 commit 29f1100
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 15 deletions.
1 change: 0 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions .idea/runConfigurations.xml

This file was deleted.

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ customVisitorToken - уникальный токен (или id) пользов

В ответ система выдаст токен (сгенерирует если вы подали null или тот же самый с которым вы зашли). Если вы пользуетесь своей системой токенов, можете игнорировать ответ.

Бывает ситуация, когда пользователь не зарегистрирован в системе и используется visitorToken, а затем пользователь проходит регистрацию и используется customVisitorToken. Для того чтобы связать до и после, передавайте оба токена в AuthData.

Для того, чтобы отключиться (и отключить автоматическое восстановление соединения) используйте метод forceDisconnect().

**События в чате**
Expand Down
9 changes: 9 additions & 0 deletions sdk/src/main/java/ru/livetex/sdk/network/AuthData.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,13 @@ public static AuthData withVisitorToken(@Nullable String visitorToken) {
public static AuthData withCustomVisitorToken(@NonNull String customVisitorToken) {
return new AuthData(null, customVisitorToken);
}

/**
* Special case - when you want to preserve user previous data with visitorToken and continue to work with your users system.
* @param visitorToken - token which were used to identify a user in past. Can't be null here.
* @param customVisitorToken - some unique token (or id) which now identifies a current user in your system. Can't be null.
*/
public static AuthData withVisitorAndCustomTokens(@NonNull String visitorToken, @NonNull String customVisitorToken) {
return new AuthData(visitorToken, customVisitorToken);
}
}
4 changes: 2 additions & 2 deletions sdk/src/main/java/ru/livetex/sdk/network/NetworkManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public Single<String> connect(@NonNull AuthData authData, boolean reconnectRequi
* @param authTokenType AuthTokenType.DEFAULT for standard (LiveTex) token system.
* @return newly generated visitorToken if param was null, or same visitorToken which was provided
*/
@Deprecated
@Deprecated // Use connect with AuthData instead
public Single<String> connect(@Nullable String visitorToken,
AuthTokenType authTokenType) {
return connect(visitorToken, authTokenType, true);
Expand All @@ -192,7 +192,7 @@ public Single<String> connect(@Nullable String visitorToken,
* @param reconnectRequired - set true to automatically reconnect (auth + websocket).
* @return newly generated visitorToken if param was null, or same visitorToken which was provided
*/
@Deprecated
@Deprecated // Use connect with AuthData instead
public Single<String> connect(@Nullable String visitorToken,
AuthTokenType authTokenType,
boolean reconnectRequired) {
Expand Down

0 comments on commit 29f1100

Please sign in to comment.