mirror of
https://gitee.com/farsunset/cim.git
synced 2025-07-27 18:40:33 +08:00
新增 实现获取离线消息的示例,完善文档
This commit is contained in:
parent
d1e486657d
commit
fa14078188
BIN
CIM客户端文档.doc
BIN
CIM客户端文档.doc
Binary file not shown.
@ -42,7 +42,9 @@
|
||||
<entry key="sessionClosedHander">
|
||||
<bean class="com.farsunset.ichat.cim.handler.SessionClosedHandler"/>
|
||||
</entry>
|
||||
|
||||
<entry key="client_get_offline_message">
|
||||
<bean class="com.farsunset.ichat.cim.handler.PushOfflineMessageHandler"/>
|
||||
</entry>
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
|
@ -0,0 +1,49 @@
|
||||
/**
|
||||
* probject:cim
|
||||
* @version 1.1.0
|
||||
*
|
||||
* @author 3979434@qq.com
|
||||
*/
|
||||
package com.farsunset.ichat.cim.handler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.farsunset.cim.nio.constant.CIMConstant;
|
||||
import com.farsunset.cim.nio.handler.CIMRequestHandler;
|
||||
import com.farsunset.cim.nio.mutual.Message;
|
||||
import com.farsunset.cim.nio.mutual.ReplyBody;
|
||||
import com.farsunset.cim.nio.mutual.SentBody;
|
||||
import com.farsunset.cim.nio.session.CIMSession;
|
||||
/**
|
||||
* 推送离线消息
|
||||
*/
|
||||
public class PushOfflineMessageHandler implements CIMRequestHandler {
|
||||
|
||||
protected final Logger logger = Logger
|
||||
.getLogger(PushOfflineMessageHandler.class);
|
||||
|
||||
public ReplyBody process(CIMSession ios, SentBody message) {
|
||||
|
||||
ReplyBody reply = new ReplyBody();
|
||||
reply.setCode(CIMConstant.ReturnCode.CODE_200);
|
||||
try {
|
||||
String account = message.get("account");
|
||||
//获取到存储的离线消息
|
||||
//List<Message> list = messageService.queryOffLineMessages(account);
|
||||
List<Message> list = new ArrayList<Message>();
|
||||
for (Message m : list) {
|
||||
|
||||
ios.write(m);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
reply.setCode(CIMConstant.ReturnCode.CODE_500);
|
||||
e.printStackTrace();
|
||||
logger.error("拉取离线消息失败", e);
|
||||
}
|
||||
return reply;
|
||||
}
|
||||
}
|
@ -42,7 +42,9 @@
|
||||
<entry key="sessionClosedHander">
|
||||
<bean class="com.farsunset.ichat.cim.handler.SessionClosedHandler"/>
|
||||
</entry>
|
||||
|
||||
<entry key="client_get_offline_message">
|
||||
<bean class="com.farsunset.ichat.cim.handler.PushOfflineMessageHandler"/>
|
||||
</entry>
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
|
@ -2,9 +2,9 @@
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="lib" path="D:/soft/adt-bundle-windows-x86_64-20140321/sdk/platforms/android-19/android.jar"/>
|
||||
<classpathentry kind="lib" path="/ichat-server/WebRoot/WEB-INF/lib/commons-lang3-3.1.jar"/>
|
||||
<classpathentry kind="lib" path="/ichat-server/WebRoot/WEB-INF/lib/log4j.jar"/>
|
||||
<classpathentry kind="lib" path="/ichat-server/WebRoot/WEB-INF/lib/netty-3.6.5.Final.jar"/>
|
||||
<classpathentry kind="lib" path="D:/android-eclipse/adt-bundle-windows-x86_64-20131030/sdk/platforms/android-19/android.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
@ -0,0 +1,49 @@
|
||||
/**
|
||||
* probject:cim
|
||||
* @version 1.1.0
|
||||
*
|
||||
* @author 3979434@qq.com
|
||||
*/
|
||||
package com.farsunset.ichat.cim.handler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.farsunset.cim.nio.constant.CIMConstant;
|
||||
import com.farsunset.cim.nio.handler.CIMRequestHandler;
|
||||
import com.farsunset.cim.nio.mutual.Message;
|
||||
import com.farsunset.cim.nio.mutual.ReplyBody;
|
||||
import com.farsunset.cim.nio.mutual.SentBody;
|
||||
import com.farsunset.cim.nio.session.CIMSession;
|
||||
/**
|
||||
* 推送离线消息
|
||||
*/
|
||||
public class PushOfflineMessageHandler implements CIMRequestHandler {
|
||||
|
||||
protected final Logger logger = Logger
|
||||
.getLogger(PushOfflineMessageHandler.class);
|
||||
|
||||
public ReplyBody process(CIMSession ios, SentBody message) {
|
||||
|
||||
ReplyBody reply = new ReplyBody();
|
||||
reply.setCode(CIMConstant.ReturnCode.CODE_200);
|
||||
try {
|
||||
String account = message.get("account");
|
||||
//获取到存储的离线消息
|
||||
//List<Message> list = messageService.queryOffLineMessages(account);
|
||||
List<Message> list = new ArrayList<Message>();
|
||||
for (Message m : list) {
|
||||
|
||||
ios.write(m);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
reply.setCode(CIMConstant.ReturnCode.CODE_500);
|
||||
e.printStackTrace();
|
||||
logger.error("拉取离线消息失败", e);
|
||||
}
|
||||
return reply;
|
||||
}
|
||||
}
|
@ -30,7 +30,9 @@
|
||||
<entry key="sessionClosedHander">
|
||||
<bean class="com.farsunset.ichat.cim.handler.SessionClosedHandler"/>
|
||||
</entry>
|
||||
|
||||
<entry key="client_get_offline_message">
|
||||
<bean class="com.farsunset.ichat.cim.handler.PushOfflineMessageHandler"/>
|
||||
</entry>
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
|
Loading…
x
Reference in New Issue
Block a user