opt websocket

This commit is contained in:
tongchenfei
2020-10-27 17:25:40 +08:00
parent 9f7a4a3a46
commit e3605a5cb4
3 changed files with 9 additions and 7 deletions

View File

@@ -5,10 +5,10 @@ import com.mogo.commons.debug.DebugConfig;
public class WebSocketConstant {
private static final String HOST_DEV = "ws://62.234.196.121:4001/ws";
private static final String HOST_QA = "ws://62.234.196.121:4001/ws";
private static final String HOST_DEMO = "ws://62.234.196.121:4001/ws";
private static final String HOST_RELEASE = "ws://62.234.196.121:4001/ws";
private static final String HOST_DEV = "ws://62.234.196.121:14001/ws";
private static final String HOST_QA = "ws://62.234.196.121:14001/ws";
private static final String HOST_DEMO = "ws://62.234.196.121:14001/ws";
private static final String HOST_RELEASE = "ws://62.234.196.121:14001/ws";
public static String getSocketServer(){
switch (DebugConfig.getNetMode()){

View File

@@ -19,9 +19,8 @@ public class WebSocketHandlerThread extends HandlerThread {
tag = name;
}
@Override
public void run() {
super.run();
public void initHandler(){
mHandler = new Handler(this.getLooper()) {
@Override
public void handleMessage(Message msg) {
@@ -34,6 +33,7 @@ public class WebSocketHandlerThread extends HandlerThread {
};
}
public void sendMsg(String msg) {
if(mHandler!=null) {
Message message = new Message();

View File

@@ -35,6 +35,7 @@ public class WebSocketManager implements IMogoWebSocketManager, ISocketMsgSettin
public WebSocketManager(Context context) {
handlerThread = new WebSocketHandlerThread(TAG);
handlerThread.start();
handlerThread.initHandler();
}
@Keep
@@ -154,6 +155,7 @@ public class WebSocketManager implements IMogoWebSocketManager, ISocketMsgSettin
@Override
public void onConnectClose() {
Logger.d(TAG, "websocket ready to reconnect");
SocketClient.getInstance().getClientProxy().stop();
SocketClient.getInstance().getClientProxy().reConnect();
}