mirror of
https://gitee.com/farsunset/cim.git
synced 2025-07-24 16:51:45 +08:00
修正doc中接口地址
This commit is contained in:
parent
9f94692734
commit
0e6f3ee400
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>com.farsunset</groupId>
|
||||
<artifactId>cim-android-sdk</artifactId>
|
||||
<version>3.8.0</version>
|
||||
<version>3.8.1</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<properties>
|
||||
@ -14,7 +14,6 @@
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<protobuf.lite.version>3.0.1</protobuf.lite.version>
|
||||
<netty.version>4.1.44.Final</netty.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
@ -62,11 +62,13 @@ class CIMCacheManager {
|
||||
}
|
||||
|
||||
public static String getString(Context context, String key) {
|
||||
String value = null;
|
||||
String value;
|
||||
ContentResolver resolver = context.getContentResolver();
|
||||
Cursor cursor = resolver.query(Uri.parse(String.format(CONTENT_URI, context.getPackageName())), new String[]{key}, null, null, null);
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
value = cursor.getString(0);
|
||||
}else {
|
||||
value = null;
|
||||
}
|
||||
closeQuietly(cursor);
|
||||
return value;
|
||||
|
@ -173,10 +173,10 @@ class CIMConnectorManager {
|
||||
}
|
||||
|
||||
public void sendHeartbeat() {
|
||||
send(HeartbeatResponse.getInstance());
|
||||
send(Pong.getInstance());
|
||||
}
|
||||
|
||||
public void send(final Protobufable body) {
|
||||
public void send(final BinaryBody body) {
|
||||
|
||||
if (!isConnected()) {
|
||||
return;
|
||||
@ -313,8 +313,8 @@ class CIMConnectorManager {
|
||||
|
||||
LOGGER.messageReceived(socketChannel, message);
|
||||
|
||||
if (message instanceof HeartbeatRequest) {
|
||||
send(HeartbeatResponse.getInstance());
|
||||
if (message instanceof Ping) {
|
||||
send(Pong.getInstance());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -56,6 +56,8 @@ public class CIMPushManager {
|
||||
|
||||
protected static final String ACTION_HIDE_PERSIST_NOTIFICATION = "ACTION_HIDE_PERSIST_NOTIFICATION";
|
||||
|
||||
protected static final String ACTION_SEND_PONG = "ACTION_SEND_PONG";
|
||||
|
||||
/**
|
||||
* 初始化,连接服务端,在程序启动页或者 在Application里调用
|
||||
*/
|
||||
@ -117,6 +119,12 @@ public class CIMPushManager {
|
||||
|
||||
}
|
||||
|
||||
public static void pong(Context context) {
|
||||
Intent serviceIntent = new Intent(context, CIMPushService.class);
|
||||
serviceIntent.setAction(ACTION_SEND_PONG);
|
||||
startService(context, serviceIntent);
|
||||
}
|
||||
|
||||
private static void sendBindRequest(Context context, String account) {
|
||||
|
||||
CIMCacheManager.putBoolean(context, CIMCacheManager.KEY_MANUAL_STOP, false);
|
||||
@ -256,7 +264,7 @@ public class CIMPushManager {
|
||||
return currDeviceId;
|
||||
}
|
||||
|
||||
String deviceId = UUID.randomUUID().toString().replaceAll("-", "").toUpperCase();
|
||||
String deviceId = UUID.randomUUID().toString().replace("-", "").toUpperCase();
|
||||
|
||||
CIMCacheManager.putString(context, CIMCacheManager.KEY_DEVICE_ID, deviceId);
|
||||
|
||||
|
@ -34,6 +34,7 @@ import android.os.IBinder;
|
||||
import android.util.Log;
|
||||
import com.farsunset.cim.sdk.android.constant.CIMConstant;
|
||||
import com.farsunset.cim.sdk.android.logger.CIMLogger;
|
||||
import com.farsunset.cim.sdk.android.model.Pong;
|
||||
import com.farsunset.cim.sdk.android.model.SentBody;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
@ -146,6 +147,10 @@ public class CIMPushService extends Service {
|
||||
handleKeepAlive();
|
||||
}
|
||||
|
||||
if (CIMPushManager.ACTION_SEND_PONG.equals(action)) {
|
||||
connectorManager.send(Pong.getInstance());
|
||||
}
|
||||
|
||||
if (CIMPushManager.ACTION_SET_LOGGER_EATABLE.equals(action)) {
|
||||
boolean enable = intent.getBooleanExtra(KEY_LOGGER_ENABLE, true);
|
||||
CIMLogger.getLogger().debugMode(enable);
|
||||
|
@ -23,7 +23,7 @@ package com.farsunset.cim.sdk.android.coder;
|
||||
|
||||
|
||||
import com.farsunset.cim.sdk.android.constant.CIMConstant;
|
||||
import com.farsunset.cim.sdk.android.model.HeartbeatRequest;
|
||||
import com.farsunset.cim.sdk.android.model.Ping;
|
||||
import com.farsunset.cim.sdk.android.model.Message;
|
||||
import com.farsunset.cim.sdk.android.model.ReplyBody;
|
||||
import com.farsunset.cim.sdk.android.model.proto.MessageProto;
|
||||
@ -73,7 +73,7 @@ public class ClientMessageDecoder {
|
||||
消息读取完成后,通过type来解析成对应的消息体
|
||||
*/
|
||||
if (CIMConstant.ProtobufType.S_H_RQ == type) {
|
||||
return HeartbeatRequest.getInstance();
|
||||
return Ping.getInstance();
|
||||
}
|
||||
|
||||
if (CIMConstant.ProtobufType.REPLY_BODY == type) {
|
||||
|
@ -22,14 +22,13 @@
|
||||
package com.farsunset.cim.sdk.android.coder;
|
||||
|
||||
import com.farsunset.cim.sdk.android.constant.CIMConstant;
|
||||
import com.farsunset.cim.sdk.android.model.Protobufable;
|
||||
import com.farsunset.cim.sdk.android.model.SentBody;
|
||||
import com.farsunset.cim.sdk.android.model.BinaryBody;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class ClientMessageEncoder {
|
||||
|
||||
public ByteBuffer encode(Protobufable body) {
|
||||
public ByteBuffer encode(BinaryBody body) {
|
||||
|
||||
byte[] data = body.getByteArray();
|
||||
|
||||
|
@ -24,7 +24,7 @@ package com.farsunset.cim.sdk.android.model;
|
||||
/**
|
||||
* 需要向另一端发送的结构体
|
||||
*/
|
||||
public interface Protobufable {
|
||||
public interface BinaryBody {
|
||||
|
||||
byte[] getByteArray();
|
||||
|
@ -28,19 +28,19 @@ import java.io.Serializable;
|
||||
/**
|
||||
* 服务端心跳请求
|
||||
*/
|
||||
public class HeartbeatRequest implements Serializable, Protobufable {
|
||||
public class Ping implements Serializable, BinaryBody {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final String TAG = "SERVER_HEARTBEAT_REQUEST";
|
||||
private static final String CMD_HEARTBEAT_REQUEST = "SR";
|
||||
|
||||
private static final HeartbeatRequest object = new HeartbeatRequest();
|
||||
private static final Ping object = new Ping();
|
||||
|
||||
private HeartbeatRequest() {
|
||||
private Ping() {
|
||||
|
||||
}
|
||||
|
||||
public static HeartbeatRequest getInstance() {
|
||||
public static Ping getInstance() {
|
||||
return object;
|
||||
}
|
||||
|
@ -28,19 +28,19 @@ import java.io.Serializable;
|
||||
/**
|
||||
* 客户端心跳响应
|
||||
*/
|
||||
public class HeartbeatResponse implements Serializable, Protobufable {
|
||||
public class Pong implements Serializable, BinaryBody {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final String TAG = "CLIENT_HEARTBEAT_RESPONSE";
|
||||
private static final String CMD_HEARTBEAT_RESPONSE = "CR";
|
||||
|
||||
private static final HeartbeatResponse object = new HeartbeatResponse();
|
||||
private static final Pong object = new Pong();
|
||||
|
||||
private HeartbeatResponse() {
|
||||
private Pong() {
|
||||
|
||||
}
|
||||
|
||||
public static HeartbeatResponse getInstance() {
|
||||
public static Pong getInstance() {
|
||||
return object;
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ import java.util.Set;
|
||||
/**
|
||||
* java |android 客户端请求结构
|
||||
*/
|
||||
public class SentBody implements Serializable, Protobufable {
|
||||
public class SentBody implements Serializable, BinaryBody {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
BIN
doc/发送消息接口文档.doc
BIN
doc/发送消息接口文档.doc
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user