Commit 8cfd9f4a by patpat

增加uat环境

parent 2e3386be
package com.bgycc.smartcanteen;
public class AppConfig {
public enum Server {
DEV,
TEST,
PROD
}
public static final Server SERVER = Server.PROD;
public static String getMainWebSocketServerUrl() {
switch (SERVER) {
case DEV: return "ws://10.187.17.22:9001/websocket/%s";
case TEST: return "ws://diningservicetest.bgy.com.cn:9001/websocket/%s";
default:
case PROD: return "wss://diningservice.bgy.com.cn/websocket/%s";
}
}
}
package com.bgycc.smartcanteen
object AppConfig {
enum class Server {
DEV,
TEST,
UAT,
PROD
}
val SERVER = Server.PROD
fun getMainWebSocketServerUrl(id: String, version: String): String {
when (SERVER) {
AppConfig.Server.DEV -> return "ws://10.187.37.226:9001/websocket/$id/V$version"
AppConfig.Server.TEST -> return "ws://diningservicetest.bgy.com.cn:9001/websocket/$id/V$version"
AppConfig.Server.UAT -> return "wss://diningserviceuat.bgy.com.cn/websocket/$id"
else -> return "wss://diningservice.bgy.com.cn/websocket/$id"
}
}
}
\ No newline at end of file
......@@ -194,7 +194,7 @@ class MainActivity : BaseActivity() {
@Subscribe(threadMode = ThreadMode.MAIN)
fun onMessageEvent(event: ConnectStateEvent) {
val base = "Server: " + String.format(AppConfig.getMainWebSocketServerUrl(), App.getDeviceSN()) + " "
val base = "Server: " + AppConfig.getMainWebSocketServerUrl(App.getDeviceSN(), BuildConfig.VERSION_NAME) + " "
if (event.state == ConnectStateEvent.OFFLINE) _server.text = base + "${NetworkManager.currentTypeString} 未连接"
else if (event.state == ConnectStateEvent.CONNECTING) _server.text = base + "${NetworkManager.currentTypeString} 正在连接..."
else if (event.state == ConnectStateEvent.CONNECTED) _server.text = base + "${NetworkManager.currentTypeString} 已连接"
......
package com.bgycc.smartcanteen.server.websocket;
import android.util.LongSparseArray;
import android.util.SparseArray;
import com.bgycc.smartcanteen.App;
import com.bgycc.smartcanteen.AppConfig;
import com.bgycc.smartcanteen.BuildConfig;
import com.bgycc.smartcanteen.action.ActionEnum;
import com.bgycc.smartcanteen.action.PayOfflineAction;
import com.bgycc.smartcanteen.action.UpdateAction;
import com.bgycc.smartcanteen.helper.TimerHelper;
import com.bgycc.smartcanteen.manager.NetworkManager;
import com.bgycc.smartcanteen.server.websocket.event.ConnectStateEvent;
import com.bgycc.smartcanteen.server.websocket.event.RecvMessageEvent;
import com.bgycc.smartcanteen.server.websocket.event.SendMessageEvent;
......@@ -56,7 +54,7 @@ public class MainWebSocket extends WebSocketClient {
if (sDeviceSN.isEmpty()) return;
EventBus.getDefault().post(new ConnectStateEvent(ConnectStateEvent.CONNECTING));
sInstance = new MainWebSocket(new URI(String.format(AppConfig.getMainWebSocketServerUrl(), sDeviceSN)));
sInstance = new MainWebSocket(new URI(AppConfig.INSTANCE.getMainWebSocketServerUrl(sDeviceSN, BuildConfig.VERSION_NAME)));
sInstance.connect();
TimerHelper.INSTANCE.loop(new TimerHelper.LoopTask() {
@Override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment