Java 类org.jivesoftware.smack.packet.id.StanzaIdUtil 实例源码

项目:BizareChat    文件:ChatRoomPresenterImpl.java   
public void sendMessage(String message) {
    if (message.trim().isEmpty()) {
        return;
    }
    if (!isMessageLengthValid(message)) {
        getViewState().showToLargeMessage();
        return;
    }
    long timestamp = System.currentTimeMillis() / 1000;
    String stanzaId = StanzaIdUtil.newStanzaId();
    saveOutgoingMessageToDb(message, timestamp, stanzaId);
    if (type == DialogsType.PRIVATE_CHAT) {
        sendPrivateMessage(message, timestamp, stanzaId);
    } else {
        sendPublicMessage(message, timestamp, stanzaId);
    }
}
项目:BizareChat    文件:QuickbloxGroupXmppConnection.java   
public void sendMessage(String body, String chatJid, long timestamp) throws SmackException {
    Random random = new Random(timestamp + body.length() + chatJid.length());
    Log.d(TAG, "Sending message to : " + chatJid);
    MultiUserChat chat = MultiUserChatManager.getInstanceFor(groupChatConnection)
            .getMultiUserChat(chatJid);
    chat.addMessageListener(this);

    Message message = new Message();
    QuickbloxChatExtension extension = new QuickbloxChatExtension();
    extension.setProperty("date_sent", timestamp + "");
    message.setStanzaId(StanzaIdUtil.newStanzaId());
    message.setBody(body);
    message.addExtension(extension);
    message.setType(Message.Type.chat);

    chat.sendMessage(message);
}
项目:BizareChat    文件:QuickbloxPrivateXmppConnection.java   
public void sendDisplayedReceipt(String receiverJid, String stanzaId, String dialog_id) {
    Chat chat;
    if ((chat = privateChats.get(receiverJid)) == null) {
        chat = ChatManager.getInstanceFor(privateChatConnection).createChat(receiverJid, this);
        privateChats.put(receiverJid, chat);
    }

    Message message = new Message(receiverJid);
    Displayed read = new Displayed(stanzaId);
    QuickbloxChatExtension extension = new QuickbloxChatExtension();
    extension.setProperty("dialog_id", dialog_id);

    message.setStanzaId(StanzaIdUtil.newStanzaId());
    message.setType(Message.Type.chat);
    message.addExtension(read);
    message.addExtension(extension);

    try {
        chat.sendMessage(message);
    } catch (SmackException.NotConnectedException ex) {
        Logger.logExceptionToFabric(ex);
        offlineMessages.add(message);
    }
}
项目:BizareChat    文件:QuickbloxPrivateXmppConnection.java   
public void sendReceivedReceipt(String receiverJid, String stanzaId, String dialog_id) {
    Chat chat;
    if ((chat = privateChats.get(receiverJid)) == null) {
        chat = ChatManager.getInstanceFor(privateChatConnection).createChat(receiverJid, this);
        privateChats.put(receiverJid, chat);
    }

    Message message = new Message(receiverJid);
    Received delivered = new Received(stanzaId);
    QuickbloxChatExtension extension = new QuickbloxChatExtension();
    extension.setProperty("dialog_id", dialog_id);

    message.setStanzaId(StanzaIdUtil.newStanzaId());
    message.setType(Message.Type.chat);
    message.addExtension(delivered);
    message.addExtension(extension);

    try {
        chat.sendMessage(message);
    } catch (SmackException.NotConnectedException ex) {
        offlineMessages.add(message);
    }
}
项目:Smack    文件:VCardManager.java   
/**
 * Save this vCard for the user connected by 'connection'. XMPPConnection should be authenticated
 * and not anonymous.
 *
 * @throws XMPPErrorException thrown if there was an issue setting the VCard in the server.
 * @throws NoResponseException if there was no response from the server.
 * @throws NotConnectedException 
 */
public void saveVCard(VCard vcard) throws NoResponseException, XMPPErrorException, NotConnectedException {
    // XEP-54 § 3.2 "A user may publish or update his or her vCard by sending an IQ of type "set" with no 'to' address…"
    vcard.setTo(null);
    vcard.setType(IQ.Type.set);
    // Also make sure to generate a new stanza id (the given vcard could be a vcard result), in which case we don't
    // want to use the same stanza id again (although it wouldn't break if we did)
    vcard.setStanzaId(StanzaIdUtil.newStanzaId());
    connection().createPacketCollectorAndSend(vcard).nextResultOrThrow();
}
项目:Intercloud    文件:RestIQ.java   
/**
     * This constructor should only be called by the client builder
     * @param uri
     * @param doc
     */
    public RestIQ(XmppURI uri, ResourceDocument doc) {
        this(doc);
        this.setStanzaId(StanzaIdUtil.newStanzaId());
        this.uri = uri;
        this.setType(Type.set);
        this.setTo(uri.getJID());

        if(this.doc.getResource() == null)
            this.doc.addNewResource().setPath(this.uri.getPath());

//      System.out.println("RestIQ was created with doc=" + this.doc.toString());

    }
项目:Intercloud    文件:GetXwadlIQ.java   
public GetXwadlIQ(XmppURI uri) {
    super(ELEMENT, NAMESPACE);
    this.setStanzaId(StanzaIdUtil.newStanzaId());
    this.uri = uri;
    this.setType(Type.get);
    this.setTo(uri.getJID());
}
项目:Smack    文件:Stanza.java   
protected Stanza() {
    this(StanzaIdUtil.newStanzaId());
}
项目:Smack    文件:DeliveryReceiptRequest.java   
/**
 * Add a delivery receipt request to an outgoing packet.
 *
 * Only message packets may contain receipt requests as of XEP-0184,
 * therefore only allow Message as the parameter type.
 *
 * @param message Message object to add a request to
 * @return the Message ID which will be used as receipt ID
 */
public static String addTo(Message message) {
    if (message.getStanzaId() == null) {
        message.setStanzaId(StanzaIdUtil.newStanzaId());
    }
    message.addExtension(new DeliveryReceiptRequest());
    return message.getStanzaId();
}
项目:Smack    文件:Presence.java   
/**
 * Clone this presence and set a newly generated stanza ID as the clone's ID.
 *
 * @return a "clone" of this presence  with a different stanza ID.
 * @since 4.1.2
 */
public Presence cloneWithNewId() {
    Presence clone = clone();
    clone.setStanzaId(StanzaIdUtil.newStanzaId());
    return clone;
}