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