// 这是一个依赖云引擎完成签名的示例
public class KeepAliveSignatureFactory implements SignatureFactory {
@Override
public Signature createSignature(String peerId, List watchIds) throws SignatureException {
Map params = new HashMap();
params.put("self_id",peerId);
params.put("watch_ids",watchIds);
try{
Object result = AVCloud.callFunction("sign",params);
if(result instanceof Map){
Map serverSignature = (Map) result;
Signature signature = new Signature();
signature.setSignature((String)serverSignature.get("signature"));
signature.setTimestamp((Long)serverSignature.get("timestamp"));
signature.setNonce((String)serverSignature.get("nonce"));
return signature;
}
}catch(AVException e){
throw (SignatureFactory.SignatureException) e;
}
return null;
}
@Override
public Signature createConversationSignature(String convId, String peerId,
List targetPeerIds,String action) throws SignatureException{
Map params = new HashMap();
params.put("client_id",peerId);
params.put("conv_id",convId);
params.put("members",targetPeerIds);
params.put("action",action);
try{
Object result = AVCloud.callFunction("sign2",params);
if(result instanceof Map){
Map serverSignature = (Map) result;
Signature signature = new Signature();
signature.setSignature((String)serverSignature.get("signature"));
signature.setTimestamp((Long)serverSignature.get("timestamp"));
signature.setNonce((String)serverSignature.get("nonce"));
return signature;
}
}catch(AVException e){
throw (SignatureFactory.SignatureException) e;
}
return null;
}
@Override
public Signature createBlacklistSignature(String clientId, String conversationId, List memberIds,
String action) throws SignatureException {
Map params = new HashMap();
params.put("client_id",clientId);
params.put("conv_id",conversationId);
params.put("members",memberIds);
params.put("action",action);
try{
Object result = AVCloud.callFunction("sign3",params);
if(result instanceof Map){
Map<String,Object> serverSignature = (Map<String,Object>) result;
Signature signature = new Signature();
signature.setSignature((String)serverSignature.get("signature"));
signature.setTimestamp((Long)serverSignature.get("timestamp"));
signature.setNonce((String)serverSignature.get("nonce"));
return signature;
}
}catch(AVException e){
throw (SignatureFactory.SignatureException) e;
}
return null;
}
}
// 将签名工厂类的实例绑定到 AVIMClient 上
AVIMOptions.getGlobalOptions().setSignatureFactory(new KeepAliveSignatureFactory());
没有找到签名的入口