dev
This commit is contained in:
@@ -40,4 +40,9 @@ public class MogoServicePaths {
|
||||
*/
|
||||
@Keep
|
||||
public static final String PATH_SERVICES_NETWORK = "/networkservices/api";
|
||||
|
||||
/**
|
||||
* netty 长链
|
||||
*/
|
||||
public static final String PATH_SOCKET_MANAGER = "/socket/manager";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.mogo.service.connection;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-01-01
|
||||
* <p>
|
||||
* 消息回执监听
|
||||
*/
|
||||
public interface IMogoMsgAckListener {
|
||||
|
||||
/**
|
||||
* 消息回执
|
||||
*/
|
||||
void onAck( long msgId );
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.mogo.service.connection;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-31
|
||||
* <p>
|
||||
* 消息回调
|
||||
*/
|
||||
public interface IMogoOnMessageListener< T > {
|
||||
|
||||
Class< T > target();
|
||||
|
||||
void onMsgReceived( T obj );
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.mogo.service.connection;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.facade.template.IProvider;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-31
|
||||
* <p>
|
||||
* socket 长链
|
||||
*/
|
||||
public interface IMogoSocketManager extends IProvider {
|
||||
|
||||
/**
|
||||
* 初始化,各模块不用关心
|
||||
*
|
||||
* @param context 上下文
|
||||
* @param appId 一般为包名
|
||||
*/
|
||||
void init( Context context, String appId );
|
||||
|
||||
/**
|
||||
* 注册消息监听
|
||||
*
|
||||
* @param msgType 消息类型
|
||||
* @param listener 回调
|
||||
*/
|
||||
void registerOnMessageListener( int msgType, IMogoOnMessageListener listener );
|
||||
|
||||
/**
|
||||
* 注销消息监听
|
||||
*
|
||||
* @param msgType 消息类型
|
||||
*/
|
||||
void unregisterOnMessageListener( int msgType );
|
||||
|
||||
/**
|
||||
* 发送消息
|
||||
*
|
||||
* @param body 消息体
|
||||
* @param listener 回执监听
|
||||
*/
|
||||
void sendMsg( MsgBody body, IMogoMsgAckListener listener );
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.mogo.service.connection;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-31
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class MsgBody {
|
||||
|
||||
/**
|
||||
* 消息类型
|
||||
*/
|
||||
private int mMsgType;
|
||||
|
||||
// /**
|
||||
// * 服务端分发,业务线
|
||||
// */
|
||||
// private int mProductLine = MogoCommon.Product.mogoBussiness_VALUE;
|
||||
//
|
||||
// /**
|
||||
// *
|
||||
// */
|
||||
// private int mHeaderType = MogoConnsvr.MsgType.mogoMsgTypeDispatchSvrNoRspReq_VALUE;
|
||||
|
||||
/**
|
||||
* 是否回执
|
||||
*/
|
||||
private boolean mAck = false;
|
||||
|
||||
/**
|
||||
* 消息ID
|
||||
*/
|
||||
private final long mMsgId = System.currentTimeMillis();
|
||||
|
||||
/**
|
||||
* 消息内容
|
||||
*/
|
||||
private Object mContent;
|
||||
|
||||
public MsgBody msgType( int msgType ) {
|
||||
this.mMsgType = msgType;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MsgBody ack( boolean ack ) {
|
||||
this.mAck = ack;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MsgBody content( Object object ) {
|
||||
this.mContent = object;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getMsgType() {
|
||||
return mMsgType;
|
||||
}
|
||||
|
||||
public boolean isAck() {
|
||||
return mAck;
|
||||
}
|
||||
|
||||
public long getMsgId() {
|
||||
return mMsgId;
|
||||
}
|
||||
|
||||
public Object getContent() {
|
||||
return mContent;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user