\r
ServerHandler(CoreService param1CoreService) { this.mReference = new WeakReference(param1CoreService); }\r
\r
- public void onConnectionClose() {\r
+ @Override\r
+ public void onConnectionClose(String errorName) {\r
CoreService coreService = (CoreService)this.mReference.get();\r
if (coreService == null)\r
return;\r
- ICLogger.i("onConnectionClose++ retry to connect again!");\r
- coreService.connectionServiceChain.processConnectionClose(coreService.connection, coreService.runtime);\r
+ ICLogger.i("onConnectionClose++ retry to connect again! Close Error "+errorName);\r
+ coreService.connectionServiceChain.processConnectionClose(coreService.connection, coreService.runtime,errorName);\r
}\r
-\r
+ @Override\r
public void onConnectionOpen() {\r
CoreService coreService = (CoreService)this.mReference.get();\r
if (coreService == null)\r
intentFilter.addAction("android.intent.action.SIM_STATE_CHANGED");\r
(paramRuntime.getContextProxy()).context.registerReceiver(this.SimStateReceive, intentFilter);\r
}\r
- \r
- public boolean onConnectionClose(Connection paramConnection, Runtime paramRuntime) { return false; }\r
+\r
+ @Override\r
+ public boolean onConnectionClose(Connection paramConnection, Runtime paramRuntime, String ErrorMsg) {\r
+ return false; }\r
\r
public boolean onConnectionOpen(Connection paramConnection, Runtime paramRuntime) { return false; }\r
\r
public void onAlarmClock(Connection paramConnection, Runtime paramRuntime) {}\r
\r
public void onAttach(Connection paramConnection, Runtime paramRuntime) {}\r
- \r
- public boolean onConnectionClose(Connection paramConnection, Runtime paramRuntime) { return false; }\r
+\r
+ @Override\r
+ public boolean onConnectionClose(Connection paramConnection, Runtime paramRuntime, String ErrorMsg) {\r
+ return false; }\r
\r
public boolean onConnectionOpen(Connection paramConnection, Runtime paramRuntime) { return false; }\r
\r
}\r
\r
public void onAttach(Connection paramConnection, Runtime paramRuntime) { this.mInstance = SimSignalUtil.getInstance((paramRuntime.getContextProxy()).context); }\r
- \r
- public boolean onConnectionClose(Connection paramConnection, Runtime paramRuntime) {\r
+\r
+ @Override\r
+ public boolean onConnectionClose(Connection paramConnection, Runtime paramRuntime, String ErrorMsg) {\r
+\r
initOK=false;\r
return false;\r
}\r
this.mShutDownReceiver = new ShutDownReceiver();\r
this.mContext.registerReceiver(this.mShutDownReceiver, intentFilter);\r
}\r
- \r
- public boolean onConnectionClose(Connection paramConnection, Runtime paramRuntime) {\r
+\r
+ @Override\r
+ public boolean onConnectionClose(Connection paramConnection, Runtime paramRuntime, String ErrorMsg) {\r
+\r
\r
// if (isConnected)\r
//如果KeepAlive被关闭说明网络有问题,因此开启重试联网机制\r
stopResponseCheckTimer();\r
- CoreService.getInstance().startConnectionRetryTimer();\r
+ if (!ErrorMsg.equals("DIS_CONNECT_BY_SERVERSIDE")){\r
+ CoreService.getInstance().startConnectionRetryTimer();\r
+ }else{\r
+ ICLogger.i("服务器主动断开,IMEI不对或者命令格式错误!停止重试连接服务器,等待重启或者下一次网络重连。");\r
+ }\r
connectionError = true;\r
isConnected = false;\r
paramRuntime.setServerProtocolConnected(false);\r
// CoreService.needLocateInAfterHeartBeat=true;\r
return false;\r
}\r
-\r
- public boolean onConnectionOpen(Connection paramConnection, Runtime paramRuntime) {\r
+ public boolean onConnectionOpen(Connection paramConnection, Runtime paramRuntime) {\r
\r
StringBuilder stringBuilder = new StringBuilder();\r
stringBuilder.append("onConnectionOpen connectionError=");\r
public void onAlarmClock(Connection paramConnection, Runtime paramRuntime) {}\r
\r
public void onAttach(Connection paramConnection, Runtime paramRuntime) {}\r
- \r
- public boolean onConnectionClose(Connection paramConnection, Runtime paramRuntime) { return this.synchronousTimeOK ^ true; }\r
+\r
+ @Override\r
+ public boolean onConnectionClose(Connection paramConnection, Runtime paramRuntime, String ErrorMsg) {\r
+ return this.synchronousTimeOK ^ true; }\r
\r
@Override\r
public boolean onConnectionOpen(Connection paramConnection, Runtime paramRuntime) {\r
this.nextService.processAttach(paramConnection, paramRuntime); \r
}\r
\r
- public final void processConnectionClose(Connection paramConnection, Runtime paramRuntime) {\r
+ public final void processConnectionClose(Connection paramConnection, Runtime paramRuntime,String ErrorMsg) {\r
if (this.isDetach)\r
return; \r
- if (!onConnectionClose(paramConnection, paramRuntime) && this.nextService != null)\r
- this.nextService.processConnectionClose(paramConnection, paramRuntime); \r
+ if (!onConnectionClose(paramConnection, paramRuntime,ErrorMsg) && this.nextService != null)\r
+ this.nextService.processConnectionClose(paramConnection, paramRuntime,ErrorMsg);\r
}\r
\r
public final void processConnectionOpen(Connection paramConnection, Runtime paramRuntime) {\r
import com.enqualcomm.support.bean.Runtime;\r
\r
public interface ConnectionService extends BaseService {\r
- boolean onConnectionClose(Connection paramConnection, Runtime paramRuntime);\r
+ boolean onConnectionClose(Connection paramConnection, Runtime paramRuntime,String ErrorMsg);\r
\r
boolean onConnectionOpen(Connection paramConnection, Runtime paramRuntime);\r
\r
import com.enqualcomm.support.bean.StringMessage;\r
\r
public interface ConnectionListener {\r
- void onConnectionClose();\r
+ void onConnectionClose(String errorName);\r
\r
void onConnectionOpen();\r
\r
if (NettyConnection.this.listener!=null){\r
NettyConnection.this.listener.onConnectionOpen();\r
}\r
- }else if (socketStatus.name().equals("DIS_CONNECT")) {\r
+ }else if (socketStatus.name().equals("DIS_CONNECT") || socketStatus.name().equals("DIS_CONNECT_BY_SERVERSIDE")) {\r
if (NettyConnection.this.listener!=null){\r
- NettyConnection.this.listener.onConnectionClose();\r
+ NettyConnection.this.listener.onConnectionClose(socketStatus.name());\r
}\r
disconnectServer();\r
}\r
@Override
public void call(Subscriber<? super Boolean> subscriber) {
try {
- if (socketStatus == SocketStatus.DIS_CONNECT) {
+ if (socketStatus == SocketStatus.DIS_CONNECT || socketStatus == SocketStatus.DIS_CONNECT_BY_SERVERSIDE) {
subscriber.onNext(true);
subscriber.onCompleted();
}
ICLogger.log(TAG,"ReadThread:"+"start");
while (isReadThreadAlive) {
//连接
- if (socketStatus == SocketStatus.DIS_CONNECT) {
+ if (socketStatus == SocketStatus.DIS_CONNECT || socketStatus == SocketStatus.DIS_CONNECT_BY_SERVERSIDE) {
try {
if (selectionKey != null) selectionKey.cancel();
socketChannel = SocketChannel.open();
if (length <= 0) {
ICLogger.log( TAG, "服务器主动断开链接!");
isReadThreadAlive = false;
- socketStatus = SocketStatus.DIS_CONNECT;
- connectStatus.onNext(SocketStatus.DIS_CONNECT);
+ socketStatus = SocketStatus.DIS_CONNECT_BY_SERVERSIDE;
+ connectStatus.onNext(SocketStatus.DIS_CONNECT_BY_SERVERSIDE);
if (socketReconnectCallback!=null)
socketReconnectCallback.onFail("SocketConnectFail3");
public enum SocketStatus {
DIS_CONNECT,
+ DIS_CONNECT_BY_SERVERSIDE,
CONNECTING,
CONNECTED,
}