This commit is contained in:
wangcongtao
2020-01-02 12:05:52 +08:00
parent 05bd793763
commit aa51e04589
40 changed files with 3941 additions and 3323 deletions

View File

@@ -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";
}

View File

@@ -0,0 +1,15 @@
package com.mogo.service.connection;
/**
* @author congtaowang
* @since 2020-01-01
* <p>
* 消息回执监听
*/
public interface IMogoMsgAckListener {
/**
* 消息回执
*/
void onAck( long msgId );
}

View File

@@ -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 );
}

View File

@@ -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 );
}

View File

@@ -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;
}
}