本文整理了Java中org.jivesoftware.smack.packet.Message.addExtension()
方法的一些代码示例,展示了Message.addExtension()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.addExtension()
方法的具体详情如下:
包路径:org.jivesoftware.smack.packet.Message
类名称:Message
方法名:addExtension
暂无
代码示例来源:origin: igniterealtime/Smack
/**
* Add a SpoilerElement to a message.
*
* @param message message to add the Spoiler to.
*/
public static void addSpoiler(Message message) {
message.addExtension(SpoilerElement.EMPTY);
}
代码示例来源:origin: igniterealtime/Smack
@Override
public void processStanza(Stanza packet)
throws
NotConnectedException,
InterruptedException,
SmackException.NotLoggedInException {
Message message = (Message) packet;
// add a markable extension
message.addExtension(ChatMarkersElements.MarkableExtension.INSTANCE);
}
}, OUTGOING_MESSAGE_FILTER);
代码示例来源:origin: igniterealtime/Smack
/**
* Creates a new message with the specified recipient and extension element.
*
* @param to
* @param extensionElement
* @since 4.2
*/
public Message(Jid to, ExtensionElement extensionElement) {
this(to);
addExtension(extensionElement);
}
代码示例来源:origin: igniterealtime/Smack
/**
* Marks a message "private", so that it will not be carbon-copied, by adding private packet
* extension to the message.
*
* @param message the message to add the private extension to
*/
public static void addTo(Message message) {
message.addExtension(INSTANCE);
}
}
代码示例来源:origin: igniterealtime/Smack
public static void setExplicitly(Message message) {
message.addExtension(INSTANCE);
}
}
代码示例来源:origin: igniterealtime/Smack
/**
* Mark a message as "private", so it will not be carbon-copied.
*
* @param msg Message object to mark private
* @deprecated use {@link Private#addTo(Message)}
*/
@Deprecated
public static void disableCarbons(Message msg) {
msg.addExtension(Private.INSTANCE);
}
}
代码示例来源:origin: igniterealtime/Smack
/**
* Add a SpoilerElement with a hint in a certain language to a message.
*
* @param message Message to add the Spoiler to.
* @param lang language of the Spoiler hint.
* @param hint hint.
*/
public static void addSpoiler(Message message, String lang, String hint) {
message.addExtension(new SpoilerElement(lang, hint));
}
代码示例来源:origin: igniterealtime/Smack
/**
* Add an origin-id element to a message and set the stanzas id to the same id as in the origin-id element.
*
* @param message message.
*/
public static OriginIdElement addOriginId(Message message) {
OriginIdElement originId = new OriginIdElement();
message.addExtension(originId);
// TODO: Find solution to have both the originIds stanzaId and a nice to look at incremental stanzaID.
// message.setStanzaId(originId.getId());
return originId;
}
代码示例来源:origin: igniterealtime/Smack
public static void addMoodToMessage(Message message, Mood mood, MoodConcretisation concretisation) {
MoodElement element = buildMood(mood, concretisation, null);
message.addExtension(element);
}
代码示例来源:origin: igniterealtime/Smack
/**
* Add a SpoilerElement with a hint to a message.
*
* @param message Message to add the Spoiler to.
* @param hint Hint about the Spoilers content.
*/
public static void addSpoiler(Message message, String hint) {
message.addExtension(new SpoilerElement(null, hint));
}
代码示例来源:origin: igniterealtime/Smack
@Override
protected synchronized void writeToXML(DataPacketExtension data) throws NotConnectedException, InterruptedException {
// create message stanza containing data packet
Message message = new Message(remoteJID);
message.addExtension(data);
connection.sendStanza(message);
}
代码示例来源:origin: igniterealtime/Smack
/**
* Add an EME element containing the specified {@code protocol} namespace to the message.
* In case there is already an element with that protocol, we do nothing.
*
* @param message message
* @param protocol encryption protocol
*/
public static void set(Message message, ExplicitMessageEncryptionProtocol protocol) {
if (!hasProtocol(message, protocol.namespace)) {
message.addExtension(new ExplicitMessageEncryptionElement(protocol));
}
}
}
代码示例来源:origin: igniterealtime/Smack
public void sendGeoLocationToJid(GeoLocation geoLocation, Jid jid) throws InterruptedException,
NotConnectedException {
final XMPPConnection connection = connection();
Message geoLocationMessage = new Message(jid);
geoLocationMessage.addExtension(geoLocation);
connection.sendStanza(geoLocationMessage);
}
代码示例来源:origin: igniterealtime/Smack
@Test
public void checkStanzas() throws Exception {
Message initialMessage = PacketParserUtils.parseStanza(initialMessageXml);
MessageCorrectExtension messageCorrectExtension = new MessageCorrectExtension(idInitialMessage);
Assert.assertEquals(messageCorrectExtension.toXML(null).toString(), messageCorrectionXml.toString());
initialMessage.addExtension(messageCorrectExtension);
Assert.assertEquals(initialMessage.toXML(null), expectedXml.toString());
}
代码示例来源:origin: igniterealtime/Smack
@Test
public void fromMessageTest() {
Message message = new Message();
assertFalse(OriginIdElement.hasOriginId(message));
assertFalse(StanzaIdElement.hasStanzaId(message));
OriginIdElement.addOriginId(message);
assertTrue(OriginIdElement.hasOriginId(message));
StanzaIdElement stanzaId = new StanzaIdElement("alice@wonderland.lit");
message.addExtension(stanzaId);
assertTrue(StanzaIdElement.hasStanzaId(message));
assertEquals(stanzaId, StanzaIdElement.getStanzaId(message));
}
}
代码示例来源:origin: igniterealtime/Smack
@Test
public void stanzaRecognitionTest() throws Exception {
String omemoXML = "<encrypted xmlns='eu.siacs.conversations.axolotl'><header sid='1009'><key rid='1337'>MwohBfRqBm2atj3fT0/KUDg59Cnvfpgoe/PLNIu1xgSXujEZEAAYACIwKh6TTC7VBQZcCcKnQlO+6s1GQ9DIRKH4JU7XrJ+JJnkPUwJ4VLSeOEQD7HmFbhQPTLZO0u/qlng=</key><iv>sN0amy4e2NBrlb4G/OjNIQ==</iv></header><payload>4xVUAeg4M0Mhk+5n3YG1x12Dw/cYTc0Z</payload></encrypted>";
OmemoElement omemoElement = new OmemoVAxolotlProvider().parse(TestUtils.getParser(omemoXML));
Message m = new Message();
m.addExtension(omemoElement);
Message n = new Message();
assertTrue(OmemoManager.stanzaContainsOmemoElement(m));
assertFalse(OmemoManager.stanzaContainsOmemoElement(n));
}
}
代码示例来源:origin: igniterealtime/Smack
@Test
public void checkReceivedExtension() throws Exception {
Message message = new Message(JidCreate.from("northumberland@shakespeare.lit/westminster"));
message.setStanzaId("message-2");
message.addExtension(new ChatMarkersElements.ReceivedExtension("message-1"));
Assert.assertEquals(receivedMessageStanza, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
}
代码示例来源:origin: igniterealtime/Smack
@Test
public void checkDisplayedExtension() throws Exception {
Message message = new Message(JidCreate.from("northumberland@shakespeare.lit/westminster"));
message.setStanzaId("message-2");
message.addExtension(new ChatMarkersElements.AcknowledgedExtension("message-1"));
Assert.assertEquals(acknowledgedMessageStanza, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
}
代码示例来源:origin: igniterealtime/Smack
@Test
public void checkMarkableExtension() throws Exception {
Message message = new Message(JidCreate.from("ingrichard@royalty.england.lit/throne"));
message.setStanzaId("message-1");
message.setBody("My lord, dispatch; read o'er these articles.");
message.addExtension(ChatMarkersElements.MarkableExtension.INSTANCE);
Assert.assertEquals(markableMessageStanza, message.toXML(null).toString());
}
代码示例来源:origin: igniterealtime/Smack
@Test
public void checkDisplayedExtension() throws Exception {
Message message = new Message(JidCreate.from("northumberland@shakespeare.lit/westminster"));
message.setStanzaId("message-2");
message.addExtension(new ChatMarkersElements.DisplayedExtension("message-1"));
Assert.assertEquals(displayedMessageStanza, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
}
内容来源于网络,如有侵权,请联系作者删除!