正在查看: OVO v3.139.0 应用的 ChatVisitorClient.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: OVO v3.139.0 应用的 ChatVisitorClient.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package zendesk.chat;
import com.google.gson.Gson;
import java.util.Collections;
import java.util.Objects;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ScheduledExecutorService;
import o.i.cg6;
import o.i.pq0;
import o.i.uz4;
import o.i.wpe;
import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import zendesk.chat.AuthenticationStorage;
import zendesk.chat.ChatSocketClient;
import zendesk.chat.MachineIdStorage;
public class ChatVisitorClient {
private static final String BASE_AUTH_URL = "https://id.zopim.com";
private static final String BASE_URL = "wss://widget-mediator.zopim.com";
private static final String USER_AGENT_FORMAT = "%s %s/%s-%s %s/%s";
private final Retrofit authenticationRetrofit;
private final AuthenticationStorage authenticationStorage;
private final ChatSocketClient chatSocketClient;
private final NetworkConnectivity connectivity;
private final Gson gson;
private final MachineIdStorage machineIdStorage;
private final ScheduledExecutorService scheduledExecutorService;
private final String sourceVersion;
private final String userAgent;
public static class Builder {
private NetworkConnectivity networkConnectivity;
private OkHttpClient okHttpClient;
private ScheduledExecutorService scheduledExecutorService;
private String appName = "_";
private String appVersion = "_";
private String sdkName = "_";
private String sdkVersion = "_";
private String baseUrl = ChatVisitorClient.BASE_URL;
private String baseAuthUrl = ChatVisitorClient.BASE_AUTH_URL;
private MachineIdStorage machineIdStorage = null;
private AuthenticationStorage authenticationStorage = null;
public ChatVisitorClient build() {
Object[] objArr = new Object[6];
String property = System.getProperty("http.agent");
if (!wpe.a(property)) {
property = "";
}
objArr[0] = property;
objArr[1] = this.appName;
objArr[2] = this.appVersion;
objArr[3] = Character.valueOf(this.baseUrl.contains("zopim.com") ? 'p' : 'd');
objArr[4] = this.sdkName;
objArr[5] = this.sdkVersion;
String format = String.format(ChatVisitorClient.USER_AGENT_FORMAT, objArr);
if (this.networkConnectivity == null) {
this.networkConnectivity = new NetworkConnectivity();
}
if (this.okHttpClient == null) {
this.okHttpClient = new OkHttpClient();
}
if (this.scheduledExecutorService == null) {
this.scheduledExecutorService = Executors.newScheduledThreadPool(5);
}
if (this.machineIdStorage == null) {
this.machineIdStorage = new MachineIdStorage.InMemory();
}
if (this.authenticationStorage == null) {
this.authenticationStorage = new AuthenticationStorage.InMemory();
}
cg6 cg6Var = new cg6();
cg6Var.g = true;
uz4 uz4Var = uz4.LOWER_CASE_WITH_UNDERSCORES;
Objects.requireNonNull(uz4Var);
cg6Var.c = uz4Var;
Gson a = cg6Var.a();
return new ChatVisitorClient(format, this.sdkVersion, new ChatSocketClient.Builder(new MediatorEndpoint(pq0.b(new StringBuilder(), this.baseUrl, "/s/W"), Clock.SYSTEM_CLOCK)).withScheduledExecutorService(this.scheduledExecutorService).withExecutor(this.scheduledExecutorService).withOkHttpClient(this.okHttpClient).build(), this.scheduledExecutorService, a, this.networkConnectivity, this.machineIdStorage, this.authenticationStorage, new Retrofit.Builder().baseUrl(this.baseAuthUrl).addConverterFactory(GsonConverterFactory.create(a)).client(this.okHttpClient).build());
}
public Builder withAppInfo(String str, String str2) {
if (wpe.a(str)) {
this.appName = str.replaceAll(" ", "");
}
if (wpe.a(str2)) {
this.appVersion = str2.replaceAll(" ", "");
}
return this;
}
public Builder withAuthenticationStorage(AuthenticationStorage authenticationStorage) {
this.authenticationStorage = authenticationStorage;
return this;
}
public Builder withBaseAuthUrl(String str) {
if (wpe.a(str)) {
this.baseAuthUrl = str;
}
return this;
}
public Builder withBaseUrl(String str) {
if (wpe.a(str)) {
this.baseUrl = str;
}
return this;
}
public Builder withMachineIdStorage(MachineIdStorage machineIdStorage) {
this.machineIdStorage = machineIdStorage;
return this;
}
public Builder withNetworkConnectivity(NetworkConnectivity networkConnectivity) {
this.networkConnectivity = networkConnectivity;
return this;
}
public Builder withOkHttpClient(OkHttpClient okHttpClient) {
this.okHttpClient = okHttpClient;
return this;
}
public Builder withScheduledExecutorService(ScheduledExecutorService scheduledExecutorService) {
this.scheduledExecutorService = scheduledExecutorService;
return this;
}
public Builder withSdkInfo(String str, String str2) {
if (wpe.a(str)) {
this.sdkName = str.replaceAll(" ", "");
}
if (wpe.a(str2)) {
this.sdkVersion = str2.replaceAll(" ", "");
}
return this;
}
}
public ChatSession createNewSession(String str, String str2, VisitorPath visitorPath) {
return createNewSession(str, "", str2, visitorPath, null);
}
private ChatVisitorClient(String str, String str2, ChatSocketClient chatSocketClient, ScheduledExecutorService scheduledExecutorService, Gson gson, NetworkConnectivity networkConnectivity, MachineIdStorage machineIdStorage, AuthenticationStorage authenticationStorage, Retrofit retrofit) {
this.userAgent = str;
this.sourceVersion = str2;
this.chatSocketClient = chatSocketClient;
this.scheduledExecutorService = scheduledExecutorService;
this.gson = gson;
this.connectivity = networkConnectivity;
this.machineIdStorage = machineIdStorage;
this.authenticationStorage = authenticationStorage;
this.authenticationRetrofit = retrofit;
}
public ChatSession createNewSession(String str, String str2, String str3, VisitorPath visitorPath) {
return createNewSession(str, str2, str3, visitorPath, null);
}
public ChatSession createNewSession(String str, String str2, String str3, VisitorPath visitorPath, JwtAuthenticator jwtAuthenticator) {
LoginDetailsProvider jwtLoginDetailsProvider;
DataNode dataNode = new DataNode(this.gson);
DataStore dataStore = new DataStore(dataNode);
LoginDetailsFactory loginDetailsFactory = new LoginDetailsFactory(str, str2, this.userAgent, this.sourceVersion, str3, visitorPath.getUrl(), visitorPath.getTitle());
if (jwtAuthenticator == null) {
jwtLoginDetailsProvider = new AnonymousLoginDetailsProvider(this.machineIdStorage, dataStore, loginDetailsFactory);
} else {
AnonymousLoginDetailsProvider anonymousLoginDetailsProvider = new AnonymousLoginDetailsProvider(this.machineIdStorage, dataStore, loginDetailsFactory);
jwtLoginDetailsProvider = new JwtLoginDetailsProvider(Clock.SYSTEM_CLOCK, jwtAuthenticator, (AuthenticationService) this.authenticationRetrofit.create(AuthenticationService.class), this.authenticationStorage, this.machineIdStorage, loginDetailsFactory, str, anonymousLoginDetailsProvider);
}
Connection connection = new Connection(dataNode, this.chatSocketClient, jwtLoginDetailsProvider, this.connectivity, this.scheduledExecutorService, dataStore.getConnectionStateMachine(), Collections.emptySet());
FileUploader fileUploader = new FileUploader(this.chatSocketClient.getOkHttpClient(), dataNode, connection);
PathValueSender pathValueSender = new PathValueSender(connection);
return new DefaultChatSession(dataStore, connection, new LinkedBlockingQueue(), pathValueSender, new RequestSender(dataNode, pathValueSender, fileUploader, dataStore.getConnectionStateMachine()), new MessageIdGenerator());
}
}