正在查看: Housing v14.7.8 应用的 QBSocketFactory.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Housing v14.7.8 应用的 QBSocketFactory.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.quickblox.chat.socket;
import com.quickblox.core.helper.Lo;
import java.io.IOException;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import javax.net.SocketFactory;
public class QBSocketFactory extends SocketFactory {
public static final int PING_INTERVAL_SECONDS = 90000;
private Socket socket;
private int socketTimeOut = PING_INTERVAL_SECONDS;
private boolean keepAlive = true;
private SocketFactory getDefaultFactory() {
return SocketFactory.getDefault();
}
private void setSockOpt(Socket socket) throws IOException {
Lo.g("Setting socket keepAlive :" + this.keepAlive);
socket.setKeepAlive(this.keepAlive);
Lo.g("Setting socket timeout :" + this.socketTimeOut);
socket.setSoTimeout(this.socketTimeOut);
socket.setTcpNoDelay(false);
}
@Override
public Socket createSocket() throws IOException {
Socket createSocket = SocketFactory.getDefault().createSocket();
this.socket = createSocket;
setSockOpt(createSocket);
return this.socket;
}
public void setKeepAlive(boolean z) {
this.keepAlive = z;
}
public void setSocketTimeOut(int i) {
this.socketTimeOut = i * 1000;
}
@Override
public Socket createSocket(String str, int i) throws IOException, UnknownHostException {
Socket createSocket = getDefaultFactory().createSocket(str, i);
this.socket = createSocket;
setSockOpt(createSocket);
return this.socket;
}
@Override
public Socket createSocket(String str, int i, InetAddress inetAddress, int i2) throws IOException, UnknownHostException {
Socket createSocket = getDefaultFactory().createSocket(str, i, inetAddress, i2);
this.socket = createSocket;
setSockOpt(createSocket);
return this.socket;
}
@Override
public Socket createSocket(InetAddress inetAddress, int i) throws IOException {
Socket createSocket = getDefaultFactory().createSocket(inetAddress, i);
this.socket = createSocket;
setSockOpt(createSocket);
return this.socket;
}
@Override
public Socket createSocket(InetAddress inetAddress, int i, InetAddress inetAddress2, int i2) throws IOException {
Socket createSocket = getDefaultFactory().createSocket(inetAddress, i, inetAddress2, i2);
this.socket = createSocket;
setSockOpt(createSocket);
return this.socket;
}
}