本文整理了Java中org.jivesoftware.smack.packet.Message.getFrom()
方法的一些代码示例,展示了Message.getFrom()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.getFrom()
方法的具体详情如下:
包路径:org.jivesoftware.smack.packet.Message
类名称:Message
方法名:getFrom
暂无
代码示例来源:origin: igniterealtime/Smack
@Override
public void processStanza(Stanza packet) {
Message message = (Message) packet;
RosterExchange rosterExchange = message.getExtension(ELEMENT, NAMESPACE);
// Fire event for roster exchange listeners
fireRosterExchangeListeners(message.getFrom(), rosterExchange.getRosterEntries());
}
};
代码示例来源:origin: igniterealtime/Smack
@Override
public void processStanza(Stanza packet) {
Message message = (Message) packet;
MessageEvent messageEvent = message.getExtension("x", "jabber:x:event");
if (messageEvent.isMessageEventRequest()) {
// Fire event for requests of message events
for (String eventType : messageEvent.getEventTypes())
fireMessageEventRequestListeners(
message.getFrom(),
message.getStanzaId(),
eventType.concat("NotificationRequested"));
} else
// Fire event for notifications of message events
for (String eventType : messageEvent.getEventTypes())
fireMessageEventNotificationListeners(
message.getFrom(),
messageEvent.getStanzaId(),
eventType.concat("Notification"));
}
}, PACKET_FILTER);
代码示例来源:origin: igniterealtime/Smack
@Override
public void processStanza(Stanza stanza) {
final Message message = (Message) stanza;
final EventElement event = EventElement.from(stanza);
assert (event != null);
final EntityBareJid from = message.getFrom().asEntityBareJidIfPossible();
assert (from != null);
asyncButOrdered.performAsyncButOrdered(from, new Runnable() {
@Override
public void run() {
for (PepListener listener : pepListeners) {
listener.eventReceived(from, event, message);
}
}
});
}
};
代码示例来源:origin: igniterealtime/Smack
OmemoMessage.Received omemoMessage = decryptMessage(managerGuard, message.getFrom().asBareJid(), element);
result.add(new MessageOrOmemoMessage(omemoMessage));
} catch (NoRawSessionException | CorruptedOmemoKeyException | CryptoFailedException e) {
LOGGER.log(Level.WARNING, "decryptMamQueryResult failed to decrypt message from "
+ message.getFrom() + " due to corrupted session/key: " + e.getMessage());
result.add(new MessageOrOmemoMessage(message));
代码示例来源:origin: igniterealtime/Smack
@Override
public void processStanza(Stanza packet) {
final Message msg = (Message) packet;
final EntityFullJid from = msg.getFrom().asEntityFullJidIfPossible();
// Update the room subject
subject = msg.getSubject();
asyncButOrdered.performAsyncButOrdered(MultiUserChat.this, new Runnable() {
@Override
public void run() {
// Fire event for subject updated listeners
for (SubjectUpdatedListener listener : subjectUpdatedListeners) {
listener.subjectUpdated(msg.getSubject(), from);
}
}
});
}
};
代码示例来源:origin: igniterealtime/Smack
@Override
public void processStanza(Stanza packet) {
Message message = (Message) packet;
Chat chat;
if (message.getThread() == null) {
// CHECKSTYLE:OFF
chat = getUserChat(message.getFrom());
// CHECKSTYLE:ON
}
else {
chat = getThreadChat(message.getThread());
}
if (chat == null) {
chat = createChat(message);
}
// The chat could not be created, abort here
if (chat == null)
return;
// TODO: Use AsyncButOrdered (with Chat as Key?)
deliverMessage(chat, message);
}
}, packetFilter);
代码示例来源:origin: igniterealtime/Smack
EntityBareJid bareFrom = message.getFrom().asEntityBareJidOrThrow();
代码示例来源:origin: igniterealtime/Smack
@Override
public void processStanza(Stanza stanza) {
final Message message = (Message) stanza;
if (!shouldAcceptMessage(message)) {
return;
}
final Jid from = message.getFrom();
final EntityFullJid fullFrom = from.asEntityFullJidOrThrow();
final EntityBareJid bareFrom = fullFrom.asEntityBareJid();
final Chat chat = chatWith(bareFrom);
chat.lockedResource = fullFrom;
asyncButOrdered.performAsyncButOrdered(chat, new Runnable() {
@Override
public void run() {
for (IncomingChatMessageListener listener : incomingListeners) {
listener.newIncomingMessage(bareFrom, message, chat);
}
}
});
}
}, INCOMING_MESSAGE_FILTER);
代码示例来源:origin: igniterealtime/Smack
/**
* Creates a new {@link Chat} based on the message. May returns null if no chat could be
* created, e.g. because the message comes without from.
*
* @param message
* @return a Chat or null if none can be created
*/
private Chat createChat(Message message) {
Jid from = message.getFrom();
// According to RFC6120 8.1.2.1 4. messages without a 'from' attribute are valid, but they
// are of no use in this case for ChatManager
if (from == null) {
return null;
}
EntityJid userJID = from.asEntityJidIfPossible();
if (userJID == null) {
LOGGER.warning("Message from JID without localpart: '" + message.toXML(null) + "'");
return null;
}
String threadID = message.getThread();
if (threadID == null) {
threadID = nextID();
}
return createChat(userJID, threadID, false);
}
代码示例来源:origin: igniterealtime/Smack
final Message message = (Message) stanza;
EntityFullJid fullFrom = message.getFrom().asEntityFullJidIfPossible();
EntityBareJid bareFrom = fullFrom.asEntityBareJid();
代码示例来源:origin: igniterealtime/Smack
@Override
public void processStanza(final Stanza stanza) throws NotConnectedException, InterruptedException {
final Message wrappingMessage = (Message) stanza;
final CarbonExtension carbonExtension = CarbonExtension.from(wrappingMessage);
final Direction direction = carbonExtension.getDirection();
final Forwarded forwarded = carbonExtension.getForwarded();
final Message carbonCopy = (Message) forwarded.getForwardedStanza();
final BareJid from = carbonCopy.getFrom().asBareJid();
carbonsListenerAsyncButOrdered.performAsyncButOrdered(from, new Runnable() {
@Override
public void run() {
for (CarbonCopyReceivedListener listener : listeners) {
listener.onCarbonCopyReceived(direction, carbonCopy, wrappingMessage);
}
}
});
}
};
代码示例来源:origin: igniterealtime/Smack
/**
* Create and return a new message including a delivery receipt extension for the given message.
* <p>
* If {@code messageWithReceiptRequest} does not have a Stanza ID set, then {@code null} will be returned.
* </p>
*
* @param messageWithReceiptRequest the given message with a receipt request extension.
* @return a new message with a receipt or <code>null</code>.
* @since 4.1
*/
public static Message receiptMessageFor(Message messageWithReceiptRequest) {
String stanzaId = messageWithReceiptRequest.getStanzaId();
if (StringUtils.isNullOrEmpty(stanzaId)) {
return null;
}
Message message = new Message(messageWithReceiptRequest.getFrom(), messageWithReceiptRequest.getType());
message.addExtension(new DeliveryReceipt(stanzaId));
return message;
}
}
代码示例来源:origin: igniterealtime/Smack
BareJid sender = carbonCopy.getFrom().asBareJid();
代码示例来源:origin: igniterealtime/Smack
@Override
public void processStanza(Stanza packet) {
final Message message = (Message) packet;
// Get the MUCUser extension
final MUCUser mucUser = MUCUser.from(message);
// Check if the MUCUser extension includes an invitation
if (mucUser.getInvite() != null) {
EntityBareJid mucJid = message.getFrom().asEntityBareJidIfPossible();
if (mucJid == null) {
LOGGER.warning("Invite to non bare JID: '" + message.toXML(null) + "'");
return;
}
// Fire event for invitation listeners
final MultiUserChat muc = getMultiUserChat(mucJid);
final XMPPConnection connection = connection();
final MUCUser.Invite invite = mucUser.getInvite();
final EntityJid from = invite.getFrom();
final String reason = invite.getReason();
final String password = mucUser.getPassword();
for (final InvitationListener listener : invitationsListeners) {
listener.invitationReceived(connection, muc, from, reason, password, message, invite);
}
}
}
};
代码示例来源:origin: igniterealtime/Smack
BareJid bareFrom = friendMessage.getFrom().asBareJid();
if (!friendshipDeniedCache.containsKey(bareFrom)) {
LOGGER.log(Level.WARNING, "Ignoring friendship recommendation "
代码示例来源:origin: igniterealtime/Smack
WorkgroupInvitation inv = new WorkgroupInvitation(connection.getUser(), msg.getFrom(),
workgroupJID, sessionID, msg.getBody(),
msg.getFrom(), metaData);
代码示例来源:origin: igniterealtime/Smack
@Test
public void checkResultsParse() throws Exception {
Message message = PacketParserUtils.parseStanza(exampleResultMessage);
MamResultExtension mamResultExtension = MamResultExtension.from(message);
Assert.assertEquals(mamResultExtension.getQueryId(), "f27");
Assert.assertEquals(mamResultExtension.getId(), "28482-98726-73623");
GregorianCalendar calendar = new GregorianCalendar(2010, 7 - 1, 10, 23, 8, 25);
calendar.setTimeZone(TimeZone.getTimeZone("UTC"));
Date date = calendar.getTime();
Forwarded forwarded = mamResultExtension.getForwarded();
Assert.assertEquals(forwarded.getDelayInformation().getStamp(), date);
Message forwardedMessage = (Message) forwarded.getForwardedStanza();
Assert.assertEquals(forwardedMessage.getFrom().toString(), "witch@shakespeare.lit");
Assert.assertEquals(forwardedMessage.getTo().toString(), "macbeth@shakespeare.lit");
Assert.assertEquals(forwardedMessage.getBody(), "Hail to thee");
}
代码示例来源:origin: igniterealtime/Smack
@Test
public void checkMamResultProvider() throws Exception {
XmlPullParser parser = PacketParserUtils.getParserFor(exampleMamResultXml);
MamResultExtension mamResultExtension = new MamResultProvider().parse(parser);
Assert.assertEquals(mamResultExtension.getQueryId(), "f27");
Assert.assertEquals(mamResultExtension.getId(), "28482-98726-73623");
GregorianCalendar calendar = new GregorianCalendar(2010, 7 - 1, 10, 23, 8, 25);
calendar.setTimeZone(TimeZone.getTimeZone("UTC"));
Date date = calendar.getTime();
Forwarded forwarded = mamResultExtension.getForwarded();
Assert.assertEquals(forwarded.getDelayInformation().getStamp(), date);
Message message = (Message) forwarded.getForwardedStanza();
Assert.assertEquals(message.getFrom().toString(), "romeo@montague.lit/orchard");
Assert.assertEquals(message.getTo().toString(), "juliet@capulet.lit/balcony");
Assert.assertEquals(message.getBody(),
"Call me but love, and I'll be new baptized; Henceforth I never will be Romeo.");
}
代码示例来源:origin: igniterealtime/Smack
assertEquals(conOne.getUser(), mamMessage.getFrom());
assertEquals(userTwo, mamMessage.getTo());
代码示例来源:origin: igniterealtime/Smack
@Test
public void checkMamQueryResults() throws Exception {
Message message = new Message();
message.setStanzaId("iasd207");
message.setFrom(JidCreate.from("coven@chat.shakespeare.lit"));
message.setTo(JidCreate.from("hag66@shakespeare.lit/pda"));
GregorianCalendar calendar = new GregorianCalendar(2002, 10 - 1, 13, 23, 58, 37);
calendar.setTimeZone(TimeZone.getTimeZone("UTC"));
Date date = calendar.getTime();
DelayInformation delay = new DelayInformation(date);
Message forwardedMessage = new Message();
forwardedMessage.setFrom(JidCreate.from("coven@chat.shakespeare.lit/firstwitch"));
forwardedMessage.setStanzaId("162BEBB1-F6DB-4D9A-9BD8-CFDCC801A0B2");
forwardedMessage.setType(Type.chat);
forwardedMessage.setBody("Thrice the brinded cat hath mew.");
Forwarded forwarded = new Forwarded(delay, forwardedMessage);
message.addExtension(new MamResultExtension("g27", "34482-21985-73620", forwarded));
// FIXME: The order of assertEquals is reversed, fix it by switching it.
Assert.assertEquals(message.toXML(StreamOpen.CLIENT_NAMESPACE).toString(), mamQueryResultExample);
MamResultExtension mamResultExtension = MamResultExtension.from(message);
Assert.assertEquals(mamResultExtension.getId(), "34482-21985-73620");
Assert.assertEquals(mamResultExtension.getForwarded().getDelayInformation().getStamp(), date);
Message resultMessage = (Message) mamResultExtension.getForwarded().getForwardedStanza();
Assert.assertEquals(resultMessage.getFrom(), JidCreate.from("coven@chat.shakespeare.lit/firstwitch"));
Assert.assertEquals(resultMessage.getStanzaId(), "162BEBB1-F6DB-4D9A-9BD8-CFDCC801A0B2");
Assert.assertEquals(resultMessage.getType(), Type.chat);
Assert.assertEquals(resultMessage.getBody(), "Thrice the brinded cat hath mew.");
}
内容来源于网络,如有侵权,请联系作者删除!