add websocket
This commit is contained in:
@@ -8,6 +8,7 @@ import com.mogo.service.analytics.IMogoAnalytics;
|
||||
import com.mogo.service.auth.IMogoAuthManager;
|
||||
import com.mogo.service.cardmanager.IMogoCardManager;
|
||||
import com.mogo.service.connection.IMogoSocketManager;
|
||||
import com.mogo.service.connection.IMogoWebSocketManager;
|
||||
import com.mogo.service.datamanager.IMogoDataManager;
|
||||
import com.mogo.service.entrance.IMogoEntranceButtonController;
|
||||
import com.mogo.service.eventpanel.IEventPanelProvider;
|
||||
@@ -69,6 +70,11 @@ public interface IMogoServiceApis extends IProvider {
|
||||
*/
|
||||
IMogoSocketManager getSocketManagerApi( Context context );
|
||||
|
||||
/**
|
||||
* 获取WebSocket操作api
|
||||
*/
|
||||
IMogoWebSocketManager getWebSocketManagerApi( Context context );
|
||||
|
||||
/**
|
||||
* 大而全的数据管理接口
|
||||
*
|
||||
|
||||
@@ -51,6 +51,12 @@ public class MogoServicePaths {
|
||||
@Deprecated
|
||||
public static final String PATH_SOCKET_MANAGER = "/socket/manager";
|
||||
|
||||
/**
|
||||
* WebSocket 长链
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String PATH_WEB_SOCKET_MANAGER = "/websocket/manager";
|
||||
|
||||
/**
|
||||
* 状态管理接口
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.mogo.service.connection;
|
||||
|
||||
/**
|
||||
* 消息回调
|
||||
*/
|
||||
public interface IMogoOnWebSocketMessageListener< T > {
|
||||
|
||||
WebSocketMsgType getType();
|
||||
|
||||
void onMsgReceived(T obj);
|
||||
|
||||
void onError(String errorMsg);
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.mogo.service.connection;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.facade.template.IProvider;
|
||||
|
||||
public interface IMogoWebSocketManager<T> extends IProvider {
|
||||
|
||||
/**
|
||||
* 初始化,各模块不用关心
|
||||
*
|
||||
* @param context 上下文
|
||||
* @param appId 一般为包名,不参与通道的建立,一般用于发消息
|
||||
*/
|
||||
void init( Context context, String appId );
|
||||
|
||||
/**
|
||||
* 注册消息监听
|
||||
*
|
||||
* @param listener 回调
|
||||
*/
|
||||
void registerOnWebSocketMessageListener(IMogoOnWebSocketMessageListener listener );
|
||||
|
||||
/**
|
||||
* 注销消息监听
|
||||
*
|
||||
*/
|
||||
void unregisterOnWebSocketMessageListener(IMogoOnWebSocketMessageListener listener );
|
||||
|
||||
/**
|
||||
* 发送消息
|
||||
*
|
||||
* @param body 消息体
|
||||
* @param listener 回执监听
|
||||
*/
|
||||
void sendMsg( T body, IMogoOnWebSocketMessageListener listener );
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.mogo.service.connection;
|
||||
|
||||
public enum WebSocketMsgType {
|
||||
|
||||
MSG_TYPE_SELF(0,"自车数据"),
|
||||
MSG_TYPE_ADAS(1,"ADAS数据"),
|
||||
MSG_TYPE_SERVER(2,"服务端下发车辆信息");
|
||||
|
||||
private int msgType;
|
||||
private String msg;
|
||||
|
||||
WebSocketMsgType(int msgType, String msg) {
|
||||
this.msgType = msgType;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public int getMsgType() {
|
||||
return msgType;
|
||||
}
|
||||
|
||||
public void setMsgType(int msgType) {
|
||||
this.msgType = msgType;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user