Skip to content

Commit

Permalink
Revert "提交修改"
Browse files Browse the repository at this point in the history
This reverts commit 24dd562.
  • Loading branch information
徐昊 committed Dec 27, 2017
1 parent 6d6c5e7 commit 56d77d6
Show file tree
Hide file tree
Showing 13 changed files with 319 additions and 104 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ dependencies {
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:design:26.1.0'
compile 'com.google.code.gson:gson:2.8.0'
compile 'com.tonystark.android:socket:1.0.1'
compile project(':socket')
}
318 changes: 280 additions & 38 deletions server/.idea/workspace.xml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import android.content.IntentFilter;

import com.xuhao.android.libsocket.impl.abilities.IConnectionSwitchListener;
import com.xuhao.android.libsocket.sdk.bean.IPulseSendable;
import com.xuhao.android.libsocket.interfaces.IPulseSendable;
import com.xuhao.android.libsocket.sdk.ConnectionInfo;
import com.xuhao.android.libsocket.sdk.bean.ISendable;
import com.xuhao.android.libsocket.sdk.bean.OriginalData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import android.os.Message;

import com.xuhao.android.libsocket.impl.exceptions.DogDeadException;
import com.xuhao.android.libsocket.sdk.bean.IPulse;
import com.xuhao.android.libsocket.sdk.bean.IPulseSendable;
import com.xuhao.android.libsocket.interfaces.IPulse;
import com.xuhao.android.libsocket.interfaces.IPulseSendable;
import com.xuhao.android.libsocket.sdk.OkSocketOptions;
import com.xuhao.android.libsocket.sdk.connection.IConnectionManager;

Expand Down Expand Up @@ -156,6 +156,4 @@ protected void setOkOptions(OkSocketOptions okOptions) {
pulse();
}
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.xuhao.android.libsocket.impl.abilities.IWriter;
import com.xuhao.android.libsocket.impl.exceptions.WriteException;
import com.xuhao.android.libsocket.sdk.bean.IPulseSendable;
import com.xuhao.android.libsocket.interfaces.IPulseSendable;
import com.xuhao.android.libsocket.sdk.OkSocketOptions;
import com.xuhao.android.libsocket.sdk.bean.ISendable;
import com.xuhao.android.libsocket.sdk.connection.abilities.IStateSender;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.xuhao.android.libsocket.sdk.bean;
package com.xuhao.android.libsocket.interfaces;

/**
* Created by xuhao on 2017/5/18.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package com.xuhao.android.libsocket.sdk.bean;
package com.xuhao.android.libsocket.interfaces;

import com.xuhao.android.libsocket.sdk.bean.ISendable;

/**
* 心跳标记接口
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package com.xuhao.android.libsocket.sdk;

import com.xuhao.android.libsocket.impl.PulseManager;
import com.xuhao.android.libsocket.sdk.bean.IPulse;
import com.xuhao.android.libsocket.sdk.bean.IHeaderProtocol;
import com.xuhao.android.libsocket.sdk.connection.AbsReconnectionManager;
import com.xuhao.android.libsocket.sdk.connection.DefaultReconnectManager;
import com.xuhao.android.libsocket.sdk.protocol.DefaultHeaderProtocol;
import com.xuhao.android.libsocket.utils.BytesUtils;

import java.nio.ByteOrder;

Expand Down Expand Up @@ -80,10 +78,9 @@ public class OkSocketOptions {
*/
private int mMaxReadDataMB;
/**
* 心跳(脉搏)管理器
* 默认会使用{@link PulseManager}
* 是否使用阻塞Socket(不可修改,暂不提供修改方法)
*/
private IPulse mPulseManager;
private boolean isBlockSocket;
/**
* 重新连接管理器
*/
Expand Down Expand Up @@ -308,6 +305,9 @@ public ByteOrder getReadByteOrder() {
return mReadByteOrder;
}

public boolean isBlockSocket() {
return isBlockSocket;
}

public int getPulseFeedLoseTimes() {
return mPulseFeedLoseTimes;
Expand All @@ -333,6 +333,7 @@ public static OkSocketOptions getDefault() {
okOptions.mReadSingleTimeBufferBytes = 50;
okOptions.mReadByteOrder = ByteOrder.BIG_ENDIAN;
okOptions.mWriteOrder = ByteOrder.BIG_ENDIAN;
okOptions.isBlockSocket = true;
okOptions.isConnectionHolden = true;
okOptions.mPulseFeedLoseTimes = 5;
okOptions.mReconnectionManager = new DefaultReconnectManager();
Expand All @@ -352,4 +353,24 @@ public enum IOThreadMode {
*/
DUPLEX;
}

private static class DefaultHeaderProtocol implements IHeaderProtocol {

@Override
public int getHeaderLength() {
return 4;
}

@Override
public int getBodyLength(byte[] header, ByteOrder byteOrder) {
if (header == null || header.length == 0) {
return 0;
}
if (ByteOrder.BIG_ENDIAN.toString().equals(byteOrder.toString())) {
return BytesUtils.bytesToInt2(header, 0);
} else {
return BytesUtils.bytesToInt(header, 0);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import android.content.Context;

import com.xuhao.android.libsocket.sdk.bean.IPulseSendable;
import com.xuhao.android.libsocket.interfaces.IPulseSendable;
import com.xuhao.android.libsocket.sdk.bean.ISendable;
import com.xuhao.android.libsocket.sdk.bean.OriginalData;
import com.xuhao.android.libsocket.sdk.connection.interfacies.ISocketActionListener;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import android.support.annotation.CallSuper;

import com.xuhao.android.libsocket.impl.PulseManager;
import com.xuhao.android.libsocket.sdk.bean.IPulseSendable;
import com.xuhao.android.libsocket.interfaces.IPulseSendable;
import com.xuhao.android.libsocket.sdk.ConnectionInfo;
import com.xuhao.android.libsocket.sdk.bean.ISendable;
import com.xuhao.android.libsocket.sdk.bean.OriginalData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import android.content.Context;

import com.xuhao.android.libsocket.sdk.bean.IPulseSendable;
import com.xuhao.android.libsocket.interfaces.IPulseSendable;
import com.xuhao.android.libsocket.sdk.ConnectionInfo;
import com.xuhao.android.libsocket.sdk.bean.ISendable;
import com.xuhao.android.libsocket.sdk.bean.OriginalData;
Expand Down

This file was deleted.

This file was deleted.

0 comments on commit 56d77d6

Please sign in to comment.