本文整理匯總了Java中org.jivesoftware.smack.packet.Message.getExtension方法的典型用法代碼示例。如果您正苦於以下問題:Java Message.getExtension方法的具體用法?Java Message.getExtension怎麽用?Java Message.getExtension使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.jivesoftware.smack.packet.Message
的用法示例。
在下文中一共展示了Message.getExtension方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: processPacket
import org.jivesoftware.smack.packet.Message; //導入方法依賴的package包/類
@Override
public void processPacket(Packet packet) throws SmackException.NotConnectedException {
if (packet instanceof Message) {
Message inMsg = (Message) packet;
if (inMsg.getBody() != null) {
if (inMsg.getBody().endsWith(NEED_RESPONSE_MARKER)) {
if (inMsg.getExtension(NS_DELAYED) == null) {
log.debug("Will respond to message: " + inMsg.toXML());
sendResponseMessage(inMsg);
} else {
log.debug("Will not consider history message: " + inMsg.toXML());
}
} else if (inMsg.getBody().endsWith(RESPONSE_MARKER)) {
responseMessages.add(inMsg);
}
}
}
}
示例2: processMessage
import org.jivesoftware.smack.packet.Message; //導入方法依賴的package包/類
public void processMessage(Chat chat, Message message) {
ExtensionElement extension = message.getExtension(NAMESPACE);
if (extension == null) {
return;
}
ChatState state;
try {
state = ChatState.valueOf(extension.getElementName());
}
catch (Exception ex) {
return;
}
fireNewChatState(chat, state);
}
示例3: testInvitation
import org.jivesoftware.smack.packet.Message; //導入方法依賴的package包/類
public void testInvitation() {
try {
GroupChatInvitation invitation = new GroupChatInvitation("[email protected]" + getChatDomain());
Message message = new Message(getBareJID(1));
message.setBody("Group chat invitation!");
message.addExtension(invitation);
getConnection(0).sendStanza(message);
Thread.sleep(250);
Message result = (Message)collector.pollResult();
assertNotNull("Message not delivered correctly.", result);
GroupChatInvitation resultInvite = (GroupChatInvitation)result.getExtension("x",
"jabber:x:conference");
assertEquals("Invitation not to correct room", "[email protected]" + getChatDomain(),
resultInvite.getRoomAddress());
}
catch (Exception e) {
fail(e.getMessage());
}
}
示例4: receiptTest
import org.jivesoftware.smack.packet.Message; //導入方法依賴的package包/類
@Test
public void receiptTest() throws Exception {
XmlPullParser parser;
String control;
control = XMLBuilder.create("message")
.a("from", "[email protected]")
.e("request")
.a("xmlns", "urn:xmpp:receipts")
.asString(outputProperties);
parser = PacketParserUtils.getParserFor(control);
Message p = PacketParserUtils.parseMessage(parser);
DeliveryReceiptRequest drr = (DeliveryReceiptRequest)p.getExtension(
DeliveryReceiptRequest.ELEMENT, DeliveryReceipt.NAMESPACE);
assertNotNull(drr);
assertTrue(DeliveryReceiptManager.hasDeliveryReceiptRequest(p));
Message m = new Message("[email protected]", Message.Type.normal);
assertFalse(DeliveryReceiptManager.hasDeliveryReceiptRequest(m));
DeliveryReceiptRequest.addTo(m);
assertTrue(DeliveryReceiptManager.hasDeliveryReceiptRequest(m));
}
示例5: checkProvider
import org.jivesoftware.smack.packet.Message; //導入方法依賴的package包/類
@Test
public void checkProvider() throws Exception {
// @formatter:off
String properties = "<message from='[email protected]/orchard' to='[email protected]/balcony'>"
+ "<body>Neither, fair saint, if either thee dislike.</body>"
+ "<properties xmlns='http://www.jivesoftware.com/xmlns/xmpp/properties'>"
+ "<property>"
+ "<name>FooBar</name>"
+ "<value type='integer'>42</value>"
+ "</property>"
+ "</properties>"
+ "</message>";
// @formatter:on
Message message = (Message) PacketParserUtils.parseStanza(properties);
JivePropertiesExtension jpe = (JivePropertiesExtension) message.getExtension(JivePropertiesExtension.NAMESPACE);
assertNotNull(jpe);
Integer integer = (Integer) jpe.getProperty("FooBar");
assertNotNull(integer);
int fourtytwo = integer;
assertEquals(42, fourtytwo);
}
示例6: processPacket
import org.jivesoftware.smack.packet.Message; //導入方法依賴的package包/類
/**
* Handles incoming messages
*/
@SuppressWarnings("unchecked")
@Override
public void processPacket(Packet packet) {
logger.log(Level.INFO, "Received: " + packet.toXML());
Message incomingMessage = (Message) packet;
FcmPacketExtension fcmPacket = (FcmPacketExtension) incomingMessage.getExtension(Util.FCM_NAMESPACE);
String json = fcmPacket.getJson();
try {
Map<String, Object> jsonMap = (Map<String, Object>) JSONValue.parseWithException(json);
Object messageType = jsonMap.get("message_type");
if (messageType == null) {
CcsInMessage inMessage = MessageHelper.createCcsInMessage(jsonMap);
handleUpstreamMessage(inMessage); // normal upstream message
return;
}
switch (messageType.toString()) {
case "ack":
handleAckReceipt(jsonMap);
break;
case "nack":
handleNackReceipt(jsonMap);
break;
case "receipt":
handleDeliveryReceipt(jsonMap);
break;
case "control":
handleControlMessage(jsonMap);
break;
default:
logger.log(Level.INFO, "Received unknown FCM message type: " + messageType.toString());
}
} catch (ParseException e) {
logger.log(Level.INFO, "Error parsing JSON: " + json, e.getMessage());
}
}
示例7: RosterExchangeManager
import org.jivesoftware.smack.packet.Message; //導入方法依賴的package包/類
/**
* Creates a new roster exchange manager.
*
* @param connection an XMPPConnection which is used to send and receive messages.
*/
public RosterExchangeManager(XMPPConnection connection) {
weakRefConnection = new WeakReference<XMPPConnection>(connection);
// Listens for all roster exchange packets and fire the roster exchange listeners.
packetListener = new StanzaListener() {
public void processPacket(Stanza packet) {
Message message = (Message) packet;
RosterExchange rosterExchange =
(RosterExchange) message.getExtension(ELEMENT, NAMESPACE);
// Fire event for roster exchange listeners
fireRosterExchangeListeners(message.getFrom(), rosterExchange.getRosterEntries());
}
};
connection.addAsyncStanzaListener(packetListener, PACKET_FILTER);
}
示例8: init
import org.jivesoftware.smack.packet.Message; //導入方法依賴的package包/類
private void init() {
// Listens for all roster exchange packets and fire the roster exchange listeners.
packetListener = new StanzaListener() {
public void processPacket(Stanza packet) {
Message message = (Message) packet;
PEPEvent event = (PEPEvent) message.getExtension("event", "http://jabber.org/protocol/pubsub#event");
// Fire event for roster exchange listeners
firePEPListeners(message.getFrom(), event);
}
};
connection.addSyncStanzaListener(packetListener, packetFilter);
}
示例9: from
import org.jivesoftware.smack.packet.Message; //導入方法依賴的package包/類
public static Received from(Message message) {
return message.getExtension(ELEMENT, NAMESPACE);
}
示例10: from
import org.jivesoftware.smack.packet.Message; //導入方法依賴的package包/類
public static Displayed from(Message message) {
return message.getExtension(ELEMENT, NAMESPACE);
}
示例11: from
import org.jivesoftware.smack.packet.Message; //導入方法依賴的package包/類
public static Markable from(Message message) {
return message.getExtension(ELEMENT, NAMESPACE);
}
示例12: from
import org.jivesoftware.smack.packet.Message; //導入方法依賴的package包/類
public static DeliveredReceipt from(Message message) {
return message.getExtension(ELEMENT, NAMESPACE);
}
示例13: from
import org.jivesoftware.smack.packet.Message; //導入方法依賴的package包/類
public static ReadReceipt from(Message message) {
return message.getExtension(ELEMENT, NAMESPACE);
}
示例14: handlePacket
import org.jivesoftware.smack.packet.Message; //導入方法依賴的package包/類
private void handlePacket(Stanza packet) {
if (packet instanceof Message) {
Message msg = (Message)packet;
// Check to see if the user left the queue.
ExtensionElement pe = msg.getExtension("depart-queue", "http://jabber.org/protocol/workgroup");
ExtensionElement queueStatus = msg.getExtension("queue-status", "http://jabber.org/protocol/workgroup");
if (pe != null) {
fireQueueDepartedEvent();
}
else if (queueStatus != null) {
QueueUpdate queueUpdate = (QueueUpdate)queueStatus;
if (queueUpdate.getPosition() != -1) {
fireQueuePositionEvent(queueUpdate.getPosition());
}
if (queueUpdate.getRemaingTime() != -1) {
fireQueueTimeEvent(queueUpdate.getRemaingTime());
}
}
else {
// Check if a room invitation was sent and if the sender is the workgroup
MUCUser mucUser = (MUCUser)msg.getExtension("x", "http://jabber.org/protocol/muc#user");
MUCUser.Invite invite = mucUser != null ? mucUser.getInvite() : null;
if (invite != null && workgroupJID.equals(invite.getFrom())) {
String sessionID = null;
Map<String, List<String>> metaData = null;
pe = msg.getExtension(SessionID.ELEMENT_NAME,
SessionID.NAMESPACE);
if (pe != null) {
sessionID = ((SessionID)pe).getSessionID();
}
pe = msg.getExtension(MetaData.ELEMENT_NAME,
MetaData.NAMESPACE);
if (pe != null) {
metaData = ((MetaData)pe).getMetaData();
}
WorkgroupInvitation inv = new WorkgroupInvitation(connection.getUser(), msg.getFrom(),
workgroupJID, sessionID, msg.getBody(),
msg.getFrom(), metaData);
fireInvitationEvent(inv);
}
}
}
}
示例15: from
import org.jivesoftware.smack.packet.Message; //導入方法依賴的package包/類
public static XHTMLExtension from(Message message) {
return message.getExtension(ELEMENT, NAMESPACE);
}