本文整理汇总了Java中org.jivesoftware.smackx.packet.DelayInfo类的典型用法代码示例。如果您正苦于以下问题:Java DelayInfo类的具体用法?Java DelayInfo怎么用?Java DelayInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DelayInfo类属于org.jivesoftware.smackx.packet包,在下文中一共展示了DelayInfo类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendOfflineMessages
import org.jivesoftware.smackx.packet.DelayInfo; //导入依赖的package包/类
public void sendOfflineMessages() {
Cursor cursor = mContentResolver.query(ChatProvider.CONTENT_URI,
SEND_OFFLINE_PROJECTION, SEND_OFFLINE_SELECTION,
null, null);
final int _ID_COL = cursor.getColumnIndexOrThrow(ChatConstants._ID);
final int JID_COL = cursor.getColumnIndexOrThrow(ChatConstants.JID);
final int MSG_COL = cursor.getColumnIndexOrThrow(ChatConstants.MESSAGE);
final int TS_COL = cursor.getColumnIndexOrThrow(ChatConstants.DATE);
final int PACKETID_COL = cursor.getColumnIndexOrThrow(ChatConstants.PACKET_ID);
ContentValues mark_sent = new ContentValues();
mark_sent.put(ChatConstants.DELIVERY_STATUS, ChatConstants.DS_SENT_OR_READ);
while (cursor.moveToNext()) {
int _id = cursor.getInt(_ID_COL);
String toJID = cursor.getString(JID_COL);
String message = cursor.getString(MSG_COL);
String packetID = cursor.getString(PACKETID_COL);
long ts = cursor.getLong(TS_COL);
Log.d(TAG, "sendOfflineMessages: " + toJID + " > " + message);
final Message newMessage = new Message(toJID, Message.Type.chat);
newMessage.setBody(message);
DelayInformation delay = new DelayInformation(new Date(ts));
newMessage.addExtension(delay);
newMessage.addExtension(new DelayInfo(delay));
newMessage.addExtension(new DeliveryReceiptRequest());
if ((packetID != null) && (packetID.length() > 0)) {
newMessage.setPacketID(packetID);
} else {
packetID = newMessage.getPacketID();
mark_sent.put(ChatConstants.PACKET_ID, packetID);
}
Uri rowuri = Uri.parse("content://" + ChatProvider.AUTHORITY
+ "/" + ChatProvider.TABLE_NAME + "/" + _id);
mContentResolver.update(rowuri, mark_sent,
null, null);
mXMPPConnection.sendPacket(newMessage); // must be after marking delivered, otherwise it may override the SendFailListener
}
cursor.close();
}
示例2: parseExtension
import org.jivesoftware.smackx.packet.DelayInfo; //导入依赖的package包/类
@Override
public PacketExtension parseExtension(XmlPullParser parser) throws Exception
{
return new DelayInfo((DelayInformation)super.parseExtension(parser));
}
示例3: sendOfflineMessages
import org.jivesoftware.smackx.packet.DelayInfo; //导入依赖的package包/类
/***************** start 发送离线消息 ***********************/
public void sendOfflineMessages() {
Cursor cursor = mContentResolver.query(ChatProvider.CONTENT_URI,
SEND_OFFLINE_PROJECTION, SEND_OFFLINE_SELECTION, null, null);// 查询数据库获取离线消息游标
final int _ID_COL = cursor.getColumnIndexOrThrow(ChatConstants._ID);
final int JID_COL = cursor.getColumnIndexOrThrow(ChatConstants.JID);
final int MSG_COL = cursor.getColumnIndexOrThrow(ChatConstants.MESSAGE);
final int TS_COL = cursor.getColumnIndexOrThrow(ChatConstants.DATE);
final int PACKETID_COL = cursor
.getColumnIndexOrThrow(ChatConstants.PACKET_ID);
ContentValues mark_sent = new ContentValues();
mark_sent.put(ChatConstants.DELIVERY_STATUS,
ChatConstants.DS_SENT_OR_READ);
while (cursor.moveToNext()) {// 遍历之后将离线消息发出
int _id = cursor.getInt(_ID_COL);
String toJID = cursor.getString(JID_COL);
String message = cursor.getString(MSG_COL);
String packetID = cursor.getString(PACKETID_COL);
long ts = cursor.getLong(TS_COL);
L.d("sendOfflineMessages: " + toJID + " > " + message);
final Message newMessage = new Message(toJID, Message.Type.chat);
newMessage.setBody(message);
DelayInformation delay = new DelayInformation(new Date(ts));
newMessage.addExtension(delay);
newMessage.addExtension(new DelayInfo(delay));
newMessage.addExtension(new DeliveryReceiptRequest());
if ((packetID != null) && (packetID.length() > 0)) {
newMessage.setPacketID(packetID);
} else {
packetID = newMessage.getPacketID();
mark_sent.put(ChatConstants.PACKET_ID, packetID);
}
Uri rowuri = Uri.parse("content://" + ChatProvider.AUTHORITY + "/"
+ ChatProvider.TABLE_NAME + "/" + _id);
// 将消息标记为已发送再调用发送,因为,假设此消息又未发送成功,有SendFailListener重新标记消息
mContentResolver.update(rowuri, mark_sent, null, null);
mXMPPConnection.sendPacket(newMessage); // must be after marking
// delivered, otherwise it
// may override the
// SendFailListener
}
cursor.close();
}
示例4: parseExtension
import org.jivesoftware.smackx.packet.DelayInfo; //导入依赖的package包/类
@Override
public PacketExtension parseExtension(XmlPullParser parser)
throws Exception {
return new DelayInfo((DelayInformation) super.parseExtension(parser));
}
示例5: sendOfflineMessages
import org.jivesoftware.smackx.packet.DelayInfo; //导入依赖的package包/类
/***************** start 发送离线消息 ***********************/
public void sendOfflineMessages() {
Cursor cursor = mContentResolver.query(ChatProvider.CONTENT_URI,
SEND_OFFLINE_PROJECTION, SEND_OFFLINE_SELECTION, null, null);// 查询数据库获取离线消息游标
final int _ID_COL = cursor.getColumnIndexOrThrow(ChatConstants._ID);
final int JID_COL = cursor.getColumnIndexOrThrow(ChatConstants.JID);
final int MSG_COL = cursor.getColumnIndexOrThrow(ChatConstants.MESSAGE);
final int TS_COL = cursor.getColumnIndexOrThrow(ChatConstants.DATE);
final int PACKETID_COL = cursor
.getColumnIndexOrThrow(ChatConstants.PACKET_ID);
ContentValues mark_sent = new ContentValues();
mark_sent.put(ChatConstants.DELIVERY_STATUS,
ChatConstants.DS_SENT_OR_READ);
while (cursor.moveToNext()) {// 遍历之后将离线消息发出
int _id = cursor.getInt(_ID_COL);
String toJID = cursor.getString(JID_COL);
String message = cursor.getString(MSG_COL);
String packetID = cursor.getString(PACKETID_COL);
long ts = cursor.getLong(TS_COL);
AppLogger.d("sendOfflineMessages: " + toJID + " > " + message);
final Message newMessage = new Message(toJID, Message.Type.chat);
newMessage.setBody(message);
DelayInformation delay = new DelayInformation(new Date(ts));
newMessage.addExtension(delay);
newMessage.addExtension(new DelayInfo(delay));
newMessage.addExtension(new DeliveryReceiptRequest());
if ((packetID != null) && (packetID.length() > 0)) {
newMessage.setPacketID(packetID);
} else {
packetID = newMessage.getPacketID();
mark_sent.put(ChatConstants.PACKET_ID, packetID);
}
Uri rowuri = Uri.parse("content://" + ChatProvider.AUTHORITY + "/"
+ ChatProvider.TABLE_NAME + "/" + _id);
// 将消息标记为已发送再调用发送,因为,假设此消息又未发送成功,有SendFailListener重新标记消息
mContentResolver.update(rowuri, mark_sent, null, null);
mXMPPConnection.sendPacket(newMessage); // must be after marking
// delivered, otherwise it
// may override the
// SendFailListener
}
cursor.close();
}
示例6: Forwarded
import org.jivesoftware.smackx.packet.DelayInfo; //导入依赖的package包/类
/**
* Creates a new Forwarded packet extension.
*
* @param delay an optional {@link DelayInfo} timestamp of the packet.
* @param fwdPacket the packet that is forwarded (required).
*/
public Forwarded(DelayInfo delay, Packet fwdPacket) {
this.delay = delay;
this.forwardedPacket = fwdPacket;
}
示例7: getDelayInfo
import org.jivesoftware.smackx.packet.DelayInfo; //导入依赖的package包/类
/**
* get the timestamp of the forwarded packet.
*
* @return the {@link DelayInfo} representing the time when the original packet was sent. May be null.
*/
public DelayInfo getDelayInfo() {
return delay;
}