本文整理匯總了Java中org.jivesoftware.smack.packet.Message.getFrom方法的典型用法代碼示例。如果您正苦於以下問題:Java Message.getFrom方法的具體用法?Java Message.getFrom怎麽用?Java Message.getFrom使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.jivesoftware.smack.packet.Message
的用法示例。
在下文中一共展示了Message.getFrom方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: sendResponseMessage
import org.jivesoftware.smack.packet.Message; //導入方法依賴的package包/類
private void sendResponseMessage(Message inMsg) {
Message outMsg = new Message(inMsg.getFrom());
outMsg.setType(inMsg.getType());
outMsg.addBody("", inMsg.getBody() + "\r\n" + System.currentTimeMillis() + "@" + RESPONSE_MARKER);
log.debug("Responding to message: " + outMsg.toXML());
try {
conn.sendPacket(outMsg);
} catch (SmackException e) {
log.error("Failed to send response", e);
}
}
示例2: createChat
import org.jivesoftware.smack.packet.Message; //導入方法依賴的package包/類
/**
* 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) {
String userJID = 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 (userJID == null) {
return null;
}
String threadID = message.getThread();
if(threadID == null) {
threadID = nextID();
}
return createChat(userJID, threadID, false);
}
示例3: sendMessage
import org.jivesoftware.smack.packet.Message; //導入方法依賴的package包/類
void sendMessage(Chat chat, Message message) throws NotConnectedException {
for(Map.Entry<MessageListener, StanzaFilter> interceptor : interceptors.entrySet()) {
StanzaFilter filter = interceptor.getValue();
if(filter != null && filter.accept(message)) {
interceptor.getKey().processMessage(message);
}
}
// Ensure that messages being sent have a proper FROM value
if (message.getFrom() == null) {
message.setFrom(connection().getUser());
}
connection().sendStanza(message);
}
示例4: 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);
}
}
}
}
示例5: receiptMessageFor
import org.jivesoftware.smack.packet.Message; //導入方法依賴的package包/類
/**
* Create and return a new message including a delivery receipt extension for the given message.
*
* @param messageWithReceiptRequest the given message with a receipt request extension.
* @return a new message with a receipt.
* @since 4.1
*/
public static Message receiptMessageFor(Message messageWithReceiptRequest) {
Message message = new Message(messageWithReceiptRequest.getFrom(), messageWithReceiptRequest.getType());
message.addExtension(new DeliveryReceipt(messageWithReceiptRequest.getStanzaId()));
return message;
}