-
Notifications
You must be signed in to change notification settings - Fork 434
Configurable
徐昊 edited this page Nov 10, 2018
·
3 revisions
- Obtain OkSocketOptions behavior belongs to the more advanced practice, each Socket connection will correspond to an OkSocketOptions, if create channel for the first time is not specified OkSocketOptions, OkSocket library will use a default configuration object.
ConnectionInfo info = new ConnectionInfo("104.238.184.237", 8080);
IConnectionManager manager = OkSocket.open(info);
//Gets the reference object for the current connection channel
OkSocketOptions options= manager.getOption();
//Build a builder class based on the current reference object
OkSocketOptions.Builder builder = new OkSocketOptions.Builder(options);
//Modify the parameter Settings (refer to the class documentation for other references)
builder.setSinglePackageBytes(size);
//Create an option and set to the socket channel
manager.option(builder.build());
manager.connect();
/**
* Socket communication mode
* IOThreadMode
* SIMPLEX Write Waiting Response
* DUPLEX Simultaneous Reading And Writing
*/
private IOThreadMode mIOThreadMode;
/**
* Whether to keep the connection cache.
* If choose `False`, OkSocket will create a new Manager
* every time when you called `OkSocket.open()`
*/
private boolean isConnectionHolden;
/**
* Write to the byte order of the server in the Socket pipe
* Default is BIG_ENDIAN
*/
private ByteOrder mWriteOrder;
/**
* Byte order when reading endianness from Socket pipe
* Default is BIG_ENDIAN
*/
private ByteOrder mReadByteOrder;
/**
* Data packet header format in Socket communication
*/
private IReaderProtocol mReaderProtocol;
/**
* The total length of a single packet when sent to the server
*/
private int mWritePackageBytes;
/**
* The length of the cache byte that is read a single time when reading from the server.
* The larger the value, the higher the read efficiency.
* But the corresponding system consumption will be larger.
*/
private int mReadPackageBytes;
/**
* Pulse frequency unit is milliseconds
*/
private long mPulseFrequency;
/**
* Allow pulse loss times
* Will be disconnected if it is greater than or equal to the number of lost times
* Throw {@link com.xuhao.didi.socket.client.impl.exceptions.DogDeadException}
*/
private int mPulseFeedLoseTimes;
/**
* Connection timeout (seconds)
*/
private int mConnectTimeoutSecond;
/**
* Megabytes of maximum read data (MB)
* Preventing the server from returning too large data in the data body causes memory to overflow.
*/
private int mMaxReadDataMB;
/**
* Reconnect manager
*/
private AbsReconnectionManager mReconnectionManager;
/**
* Secure Sockets Layer Configuration
*/
private OkSocketSSLConfig mSSLConfig;
/**
* Socket factory for custom Sockets
*/
private OkSocketFactory mOkSocketFactory;
/**
* Whether to callback from a separate thread.
* Callback from IO thread by default
*/
private boolean isCallbackInIndependentThread;
/**
* Will be distributed to the handler,
* the external needs to pass in the HandlerToken and call
* Handler.post(runnable);
*/
private ThreadModeToken mCallbackThreadModeToken;