本文整理汇总了Java中org.xmpp.packet.JID.toString方法的典型用法代码示例。如果您正苦于以下问题:Java JID.toString方法的具体用法?Java JID.toString怎么用?Java JID.toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.xmpp.packet.JID
的用法示例。
在下文中一共展示了JID.toString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: selectGeoService
import org.xmpp.packet.JID; //导入方法依赖的package包/类
private String selectGeoService() {
// dequeue and add it to the end of the queue for round-robin every 30 hits or so
synchronized (componentJids) {
JID target = componentJids.peek();
if (componentJids.size() > 1) {
if (hits.incrementAndGet() % 30 == 0) {
target = componentJids.poll();
componentJids.offer(target);
hits.set(0);
}
}
return target.toString();
}
}
示例2: processIncoming
import org.xmpp.packet.JID; //导入方法依赖的package包/类
@Override
public void processIncoming(Packet packet) {
if (packet instanceof Message) {
LOGGER.debug("Sending the same message back");
Message message = (Message) packet;
Element mmx = message.getChildElement(Constants.MMX, Constants.MMX_NS_MSG_PAYLOAD);
boolean receiptRequested = message.getChildElement(Constants.XMPP_REQUEST, Constants.XMPP_NS_RECEIPTS) != null;
JID fromJID = message.getFrom();
JID toJID = message.getTo();
message.setTo(fromJID);
Element internalMeta = mmx.element(Constants.MMX_MMXMETA);
String userId = JIDUtil.getUserId(fromJID);
String devId = fromJID.getResource();
String mmxMetaJSON = MMXMetaBuilder.build(userId, devId);
if (internalMeta != null) {
mmx.remove(internalMeta);
}
Element revisedMeta = mmx.addElement(Constants.MMX_MMXMETA);
revisedMeta.setText(mmxMetaJSON);
if (receiptRequested) {
//remove the receipt requested element to ensure we don't have a loop
message.deleteExtension(Constants.XMPP_REQUEST, Constants.XMPP_NS_RECEIPTS);
}
try {
//add a little sleep to differentiate between the send and recvd time.
Thread.sleep(1000L);
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
}
autoRespondingConnection.sendPacket(message);
/*
* Acknowledge the receipt by sending an IQ
*/
String originalMessageId = message.getID();
String from = fromJID.toString();
String to = toJID.toString();
LOGGER.debug("Attempting to deliver ack");
IQ ackIQ = buildAckIQ(from, to, originalMessageId);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Ack IQ:{}", ackIQ.toXML());
}
autoRespondingConnection.sendPacket(ackIQ);
if (receiptRequested) {
LOGGER.debug("Sending delivery receipt for message with id:{}", originalMessageId);
String appId = JIDUtil.getAppId(to);
Message receipt = buildDeliveryReceipt(appId, from, to, originalMessageId);
autoRespondingConnection.sendPacket(receipt);
} else {
LOGGER.debug("Not sending delivery receipt for message with id:{}", originalMessageId);
}
}
}
示例3: processIncoming
import org.xmpp.packet.JID; //导入方法依赖的package包/类
@Override
public void processIncoming(Packet packet) {
if (packet instanceof Message) {
Message message = (Message) packet;
JID fromJID = packet.getFrom();
JID toJID = packet.getTo();
packet.setTo(fromJID);
Element mmx = message.getChildElement(Constants.MMX, Constants.MMX_NS_MSG_PAYLOAD);
Element meta = mmx.element(Constants.MMX_META);
if (meta == null) {
LOGGER.info("No meta in the message with id:{}", message.getID());
return;
}
//Simulate SDK ack
String originalMessageId = packet.getID();
String from = fromJID.toString();
String to = toJID.toString();
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Attempting to deliver ack");
}
IQ ackIQ = BotRegistrationImpl.buildAckIQ(from, to, originalMessageId);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Ack IQ:{}", ackIQ.toXML());
}
connection.sendPacket(ackIQ);
String metaJSON = meta.getText();
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Meta JSON:{}", metaJSON);
}
RPSLSGameInfo gameInfo = GsonData.getGson().fromJson(metaJSON, RPSLSGameInfo.class);
if (gameInfo.getType() == RPSLSMessageType.INVITATION) {
//process an invitation
//step 1. Send an acceptance
//step 2. Send a choice after 2 seconds.
processRPSLSInvitationMessage(fromJID, toJID, gameInfo);
} else {
//ignore the other types
LOGGER.info("Ignoring a message with type:{} message:{}", gameInfo.getType(), message);
}
}
}