• 大小: 15.82MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-06-20
  • 语言: Java
  • 标签:

资源简介

环信测试成功demo,使用java开发.本人亲自测试过的百分百可以本地测试. 主要修改 com.easemob.lmc.tool._Global中的 public static String APP_KEY = "993006816#chanew"; public static String APP_CLIENT_ID = "YXA6Fq06cDz-EeaRUQs9b2t9CQ"; public static String APP_CLIENT_SECRET = "YXA6lCtSqTeeFMAtleO25SblDK321l0"; 即可运行项目 可以根据 参考环信开发者文档: http://docs.easemob.com/im/100serverintegration/40fileoperation 官网 http://www.easemob.com/ 解决测试中相应问题

资源截图

代码片段和文件信息

package com.easemob.lmc.model;
import java.util.HashMap;
import java.util.Map;
import org.apache.http.client.methods.HttpEntityEnclosingRequestbase;
import org.apache.http.client.methods.HttpRequestbase;
import com.easemob.lmc.service.TalkHttpService;
import com.easemob.lmc.tool._Global;
public class Authentic {
private static Token token = new Token();
private TalkHttpService service;
public Authentic(TalkHttpService service) {
this.service = service;
}
public Authentic(TalkHttpService service Token token) {
this.service = service;
if(token!=null){
Authentic.token = token;
}
}
public Token getToken() {
this.flush();
return token;
}
public void task() {
//TODO 定时刷新服务端TOKEN
this.flush();
}
public void applyAuthentication(HttpEntityEnclosingRequestbase request) {
this.flush();
request.addHeader(“Authorization““Bearer “+token.toString());
}
public void applyAuthentication(HttpRequestbase request) {
this.flush();
request.addHeader(“Authorization““Bearer “+token.toString());
}
private void flush() {
synchronized(Authentic.class){
try{
if(token.isExpire()){
if(_Global.APP_CLIENT_ID!=null&&_Global.APP_CLIENT_SECRET!=null){
Mapject>param = new HashMapject>();
param.put(“grant_type““client_credentials“);
param.put(“client_id“_Global.APP_CLIENT_ID);
param.put(“client_secret“_Global.APP_CLIENT_SECRET);
TalkNode res = service.request(_Global.URR_TOKEN_Global.HTTP_METHOD_POSTparamnullnull);
if(res!=null&&res.getAccess_token()!=null&&res.getExpires_in()!=null&&res.getExpires_in()>0){
token = new Token(res.getAccess_token()res.getExpires_in()*1000+System.currentTimeMillis());
}
}
}
}catch(Exception e){
e.printStackTrace();
}
}
}
public static class Token {
private String token;
private Long expire;
public Token() {}
public Token(String token long expire) {
this.token = token;
this.expire = expire;
}
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
public Long getExpire() {
return expire;
}
public void setExpire(Long expire) {
this.expire = expire;
}
public boolean isExpire() {
return expire==null||System.currentTimeMillis()>expire;
}
@Override
public String toString() {
return token;
}
}
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2016-08-24 13:20  环信测试成功demo\
     目录           0  2016-08-24 13:20  环信测试成功demo\chat.liaozi.net\
     文件     8293033  2016-08-24 13:20  环信测试成功demo\chat.liaozi.net.zip
     文件         419  2016-08-22 15:56  环信测试成功demo\chat.liaozi.net\.classpath
     文件        1198  2015-12-08 19:11  环信测试成功demo\chat.liaozi.net\.project
     目录           0  2016-08-24 13:20  环信测试成功demo\chat.liaozi.net\.settings\
     文件         522  2015-12-08 19:11  环信测试成功demo\chat.liaozi.net\.settings\.jsdtscope
     文件         164  2015-12-08 19:11  环信测试成功demo\chat.liaozi.net\.settings\com.genuitec.runtime.libraries.xml
     文件          57  2016-08-22 15:45  环信测试成功demo\chat.liaozi.net\.settings\org.eclipse.core.resources.prefs
     文件         364  2015-12-08 19:11  环信测试成功demo\chat.liaozi.net\.settings\org.eclipse.jdt.core.prefs
     文件         504  2015-12-08 19:11  环信测试成功demo\chat.liaozi.net\.settings\org.eclipse.wst.common.component
     文件         358  2016-08-22 15:56  环信测试成功demo\chat.liaozi.net\.settings\org.eclipse.wst.common.project.facet.core.xml
     文件          49  2015-12-08 19:11  环信测试成功demo\chat.liaozi.net\.settings\org.eclipse.wst.jsdt.ui.superType.container
     文件           6  2015-12-08 19:11  环信测试成功demo\chat.liaozi.net\.settings\org.eclipse.wst.jsdt.ui.superType.name
     目录           0  2016-08-24 13:20  环信测试成功demo\chat.liaozi.net\src\
     目录           0  2016-08-24 13:20  环信测试成功demo\chat.liaozi.net\src\com\
     目录           0  2016-08-24 13:20  环信测试成功demo\chat.liaozi.net\src\com\easemob\
     目录           0  2016-08-24 13:20  环信测试成功demo\chat.liaozi.net\src\com\easemob\lmc\
     目录           0  2016-08-24 13:20  环信测试成功demo\chat.liaozi.net\src\com\easemob\lmc\model\
     文件        2482  2016-04-07 17:16  环信测试成功demo\chat.liaozi.net\src\com\easemob\lmc\model\Authentic.java
     文件        3528  2016-04-07 16:23  环信测试成功demo\chat.liaozi.net\src\com\easemob\lmc\model\TalkMsg.java
     文件       21461  2016-08-23 14:40  环信测试成功demo\chat.liaozi.net\src\com\easemob\lmc\model\TalkNode.java
     文件        1327  2016-08-23 14:40  环信测试成功demo\chat.liaozi.net\src\com\easemob\lmc\model\TalkUserMessage.java
     目录           0  2016-08-24 13:20  环信测试成功demo\chat.liaozi.net\src\com\easemob\lmc\service\
     目录           0  2016-08-24 13:20  环信测试成功demo\chat.liaozi.net\src\com\easemob\lmc\service\impl\
     文件       16421  2016-08-23 14:50  环信测试成功demo\chat.liaozi.net\src\com\easemob\lmc\service\impl\TalkDataServiceImpl.java
     文件        5467  2016-08-23 11:25  环信测试成功demo\chat.liaozi.net\src\com\easemob\lmc\service\impl\TalkHttpServiceImplApache.java
     文件         771  2016-08-23 11:25  环信测试成功demo\chat.liaozi.net\src\com\easemob\lmc\service\impl\TalkHttpServiceImplJersey.java
     文件        9618  2016-04-07 16:53  环信测试成功demo\chat.liaozi.net\src\com\easemob\lmc\service\TalkDataService.java
     文件         955  2016-04-07 17:22  环信测试成功demo\chat.liaozi.net\src\com\easemob\lmc\service\TalkHttpService.java
     目录           0  2016-08-24 13:20  环信测试成功demo\chat.liaozi.net\src\com\easemob\lmc\tool\
............此处省略78个文件信息

评论

共有 条评论

相关资源