国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看
打開APP
未登錄
開通VIP,暢享免費電子書等14項超值服
開通VIP
首頁
好書
留言交流
下載APP
聯(lián)系客服
openfire推送離線聊天信息插件
WindySky
>《插件》
2016.03.04
關(guān)注
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.hyh.offlinemessage.plugin;
import java.io.File;
import java.io.IOException;
import java.sql.Timestamp;
import java.util.Date;
import java.util.List;
import org.jivesoftware.database.SequenceManager;
import org.jivesoftware.openfire.PresenceManager;
import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.openfire.container.Plugin;
import org.jivesoftware.openfire.container.PluginManager;
import org.jivesoftware.openfire.interceptor.InterceptorManager;
import org.jivesoftware.openfire.interceptor.PacketInterceptor;
import org.jivesoftware.openfire.interceptor.PacketRejectedException;
import org.jivesoftware.openfire.session.Session;
import org.jivesoftware.openfire.user.User;
import org.jivesoftware.openfire.user.UserManager;
import org.jivesoftware.openfire.user.UserNotFoundException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xmpp.packet.IQ;
import org.xmpp.packet.JID;
import org.xmpp.packet.Message;
import org.xmpp.packet.Packet;
import org.xmpp.packet.Presence;
import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.openfire.container.Plugin;
import org.jivesoftware.openfire.container.PluginManager;
import org.jivesoftware.openfire.user.User;
import org.jivesoftware.openfire.user.UserManager;
import org.jivesoftware.openfire.PresenceManager;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Log;
/**
* send offline msg plugin
*/
public class OfflineMsg implements PacketInterceptor, Plugin {
private static final Logger log = LoggerFactory.getLogger(OfflineMsg.class);
// Hook for intercpetorn
private InterceptorManager interceptorManager;
private static PluginManager pluginManager;
private UserManager userManager;
private PresenceManager presenceManager;
public OfflineMsg() {
}
public void debug(String str) {
if (true) {
// System.out.println(str);
}
}
public void initializePlugin(PluginManager manager, File pluginDirectory) {
interceptorManager = InterceptorManager.getInstance();
interceptorManager.addInterceptor(this);
XMPPServer server = XMPPServer.getInstance();
userManager = server.getUserManager();
presenceManager = server.getPresenceManager();
pluginManager = manager;
this.debug("start offline 1640");
}
public void destroyPlugin() {
this.debug("start offline 1640");
}
/**
* intercept message
*/
@Override
public void interceptPacket(Packet packet, Session session,
boolean incoming, boolean processed) throws PacketRejectedException {
JID recipient = packet.getTo();
if (recipient != null) {
String username = recipient.getNode();
// if broadcast message or user is not exist
if (username == null
|| !UserManager.getInstance().isRegisteredUser(recipient)) {
return;
} else if (!XMPPServer.getInstance().getServerInfo()
.getXMPPDomain().equals(recipient.getDomain())) {
// not from the same domain
return;
} else if ("".equals(recipient.getResource())) {
}
}
this.doAction(packet, incoming, processed, session);
}
/**
* send offline msg from this function
*/
private void doAction(Packet packet, boolean incoming, boolean processed,
Session session) {
Packet copyPacket = packet.createCopy();
if (packet instanceof Message) {
Message message = (Message) copyPacket;
if (message.getType() == Message.Type.chat) {
if (processed || !incoming) {
return;
}
Message sendmessage = (Message) packet;
String content = sendmessage.getBody();
JID recipient = sendmessage.getTo();
// get message
try {
if (recipient.getNode() == null
|| !UserManager.getInstance().isRegisteredUser(
recipient.getNode())) {
// Sender is requesting presence information of an
// anonymous user
throw new UserNotFoundException("Username is null");
}
Presence status = presenceManager.getPresence(userManager
.getUser(recipient.getNode()));
if (status != null) {
this.debug(recipient.getNode() + " online111"
+ ",message: " + content);
} else {
this.debug(recipient.getNode() + " offline111"
+ ",message: " + content);
/*
* add your code here to send offline msg
* recipient.getNode() : receive's id,for example,if
* receive's jid is "23@localhost", receive's id is "23"
* content: message content
*/
}// end if
} catch (UserNotFoundException e) {
this.debug("exceptoin " + recipient.getNode() + " not find"
+ ",full jid: " + recipient.toFullJID());
}
} else if (message.getType() == Message.Type.groupchat) {
List<?> els = message.getElement().elements("x");
if (els != null && !els.isEmpty()) {
} else {
}
} else {
}
} else if (packet instanceof IQ) {
IQ iq = (IQ) copyPacket;
if (iq.getType() == IQ.Type.set && iq.getChildElement() != null
&& "session".equals(iq.getChildElement().getName())) {
}
} else if (packet instanceof Presence) {
Presence presence = (Presence) copyPacket;
if (presence.getType() == Presence.Type.unavailable) {
}
}
}
}
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請
點擊舉報
。
打開APP,閱讀全文并永久保存
查看更多類似文章
猜你喜歡
類似文章
源碼詳解openfire保存消息記錄_修改服務(wù)端方式
openfire3.6.3插件開發(fā)方法(經(jīng)小組測試成功)
通過openfire發(fā)送文字
Android客戶端基于XMPP的IM(openfire+asmack)的聊天工具之環(huán)境搭建及與服務(wù)器建立連接(一)
一個gtalk的robot的簡單實現(xiàn)
java實現(xiàn)簡單XMPP發(fā)送消息和文件的簡單例子
更多類似文章 >>
生活服務(wù)
首頁
萬象
文化
人生
生活
健康
教育
職場
理財
娛樂
藝術(shù)
上網(wǎng)
留言交流
回頂部
聯(lián)系我們
分享
收藏
點擊這里,查看已保存的文章
導長圖
關(guān)注
一鍵復制
下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!
聯(lián)系客服
微信登錄中...
請勿關(guān)閉此頁面
先別劃走!
送你5元優(yōu)惠券,購買VIP限時立減!
5
元
優(yōu)惠券
優(yōu)惠券還有
10:00
過期
馬上使用
×