当前位置: 首页>>代码示例>>Java>>正文


Java SmackException.NotConnectedException方法代码示例

本文整理汇总了Java中org.jivesoftware.smack.SmackException.NotConnectedException方法的典型用法代码示例。如果您正苦于以下问题:Java SmackException.NotConnectedException方法的具体用法?Java SmackException.NotConnectedException怎么用?Java SmackException.NotConnectedException使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jivesoftware.smack.SmackException的用法示例。


在下文中一共展示了SmackException.NotConnectedException方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processPacket

import org.jivesoftware.smack.SmackException; //导入方法依赖的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);
            }
        }
    }
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:19,代码来源:SendMessage.java

示例2: sendDisplayedReceipt

import org.jivesoftware.smack.SmackException; //导入方法依赖的package包/类
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);
    }
}
 
开发者ID:ukevgen,项目名称:BizareChat,代码行数:25,代码来源:QuickbloxPrivateXmppConnection.java

示例3: sendReceivedReceipt

import org.jivesoftware.smack.SmackException; //导入方法依赖的package包/类
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);
    }
}
 
开发者ID:ukevgen,项目名称:BizareChat,代码行数:24,代码来源:QuickbloxPrivateXmppConnection.java

示例4: sendPrivateMessage

import org.jivesoftware.smack.SmackException; //导入方法依赖的package包/类
public void sendPrivateMessage(String body, String receiverJid, long timestamp, String stanzaId) {
    Log.d(TAG, "Sending message to : " + receiverJid);

    Chat chat;
    if ((chat = privateChats.get(receiverJid)) == null) {
        chat = ChatManager.getInstanceFor(privateChatConnection).createChat(receiverJid, this);
        privateChats.put(receiverJid, chat);
    }

    QuickbloxChatExtension extension = new QuickbloxChatExtension();
    extension.setProperty("date_sent", timestamp + "");
    extension.setProperty("save_to_history", "1");

    Message message = new Message(receiverJid);
    message.setStanzaId(stanzaId);
    message.setBody(body);
    message.setType(Message.Type.chat);
    message.addExtension(new Markable());
    message.addExtension(extension);

    try {
        chat.sendMessage(message);
    } catch (SmackException.NotConnectedException ex) {
        offlineMessages.add(message);
    }
}
 
开发者ID:ukevgen,项目名称:BizareChat,代码行数:27,代码来源:QuickbloxPrivateXmppConnection.java

示例5: sendPublicMessage

import org.jivesoftware.smack.SmackException; //导入方法依赖的package包/类
public void sendPublicMessage(String body, String chatJid, long timestamp, String stanzaId) {
    Log.d(TAG, "Sending message to : " + chatJid);

    MultiUserChat mucChat = publicChats.get(chatJid);

    QuickbloxChatExtension extension = new QuickbloxChatExtension();
    extension.setProperty("date_sent", timestamp + "");
    extension.setProperty("save_to_history", "1");

    Message message = new Message(chatJid);
    message.setStanzaId(stanzaId);
    message.setBody(body);
    message.setType(Message.Type.groupchat);
    message.addExtension(extension);

    try {
        if (mucChat != null) {
            mucChat.sendMessage(message);
        }
    } catch (SmackException.NotConnectedException ex) {
        offlineMessages.add(message);
    }
}
 
开发者ID:ukevgen,项目名称:BizareChat,代码行数:24,代码来源:QuickbloxPrivateXmppConnection.java

示例6: addContact

import org.jivesoftware.smack.SmackException; //导入方法依赖的package包/类
public void addContact(String jidString)
        throws SmackException.NotLoggedInException, InterruptedException,
        SmackException.NotConnectedException, XMPPException.XMPPErrorException,
        SmackException.NoResponseException, XmppStringprepException {
    Roster roster = Roster.getInstanceFor(XMPPSession.getInstance().getXMPPConnection());
    if (!roster.isLoaded()) {
        roster.reloadAndWait();
    }

    BareJid jid = JidCreate.bareFrom(jidString);
    String name = XMPPUtils.fromJIDToUserName(jidString);
    String[] groups = new String[]{"Buddies"};

    roster.createEntry(jid, name, groups);
    roster.sendSubscriptionRequest(jid);
}
 
开发者ID:esl,项目名称:mangosta-android,代码行数:17,代码来源:RosterManager.java

示例7: controlNotificationAlarm

import org.jivesoftware.smack.SmackException; //导入方法依赖的package包/类
private void controlNotificationAlarm(boolean torchMode) {
	final XMPPTCPConnection connection = mXmppManager.getXmppConnection();
	final EntityFullJid fullThingJid = mXmppManager.getFullThingJidOrNotify();
	if (fullThingJid == null) return;

	SetBoolData setTorch = new SetBoolData(Constants.NOTIFICATION_ALARM, torchMode);
	IoTControlManager ioTControlManager = IoTControlManager.getInstanceFor(connection);

	LOGGER.info("Trying to control " + fullThingJid + " set torchMode=" + torchMode);

	try {
		final IoTSetResponse ioTSetResponse = ioTControlManager.setUsingIq(fullThingJid, setTorch);
	} catch (SmackException.NoResponseException | XMPPErrorException | SmackException.NotConnectedException | InterruptedException e) {
		mXmppManager.withMainActivity((ma) -> Toast.makeText(mContext, "Could not control thing: " + e, Toast.LENGTH_LONG).show());
		LOGGER.log(Level.SEVERE, "Could not set data", e);
	}
}
 
开发者ID:Flowdalic,项目名称:android-xmpp-iot-demo,代码行数:18,代码来源:XmppIotDataControl.java

示例8: createNodeToAllowComments

import org.jivesoftware.smack.SmackException; //导入方法依赖的package包/类
public void createNodeToAllowComments(String blogPostId) {
    String nodeName = PublishCommentExtension.NODE + "/" + blogPostId;

    PubSubManager pubSubManager = PubSubManager.getInstance(XMPPSession.getInstance().getXMPPConnection());
    try {
        // create node
        ConfigureForm configureForm = new ConfigureForm(DataForm.Type.submit);
        configureForm.setPublishModel(PublishModel.open);
        configureForm.setAccessModel(AccessModel.open);
        Node node = pubSubManager.createNode(nodeName, configureForm);

        // subscribe to comments
        String myJIDString = getUser().toString();
        node.subscribe(myJIDString);
    } catch (SmackException.NoResponseException | XMPPException.XMPPErrorException | SmackException.NotConnectedException | InterruptedException e) {
        e.printStackTrace();
    }
}
 
开发者ID:esl,项目名称:mangosta-android,代码行数:19,代码来源:XMPPSession.java

示例9: processPacket

import org.jivesoftware.smack.SmackException; //导入方法依赖的package包/类
@Override
public void processPacket(Packet packet) throws SmackException.NotConnectedException {
    /** TODO: do we need to respond?
     if (packet instanceof Presence) {
     Presence presence = (Presence) packet;
     if (presence.getType() == Presence.Type.subscribe) {
     try {
     conn.getRoster().createEntry(presence.getFrom(), presence.getFrom(), new String[0]);
     } catch (SmackException.NotLoggedInException | SmackException.NoResponseException | XMPPException.XMPPErrorException e) {
     log.error("Failed to add to roster", e);
     }
     }
     }
     */
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:16,代码来源:SendPresence.java

示例10: processPacket

import org.jivesoftware.smack.SmackException; //导入方法依赖的package包/类
@Override
public void processPacket(Packet packet) throws SmackException.NotConnectedException {
    try {
        log.debug("Packet recv [" + conn.getConnectionID() + "]: " + packet.toXML());
    } catch (IllegalArgumentException e) {
        log.debug("Failed to log packet", e);
        log.debug("Packet recv [" + conn.getConnectionID() + "]: " + packet.getError());
    }
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:10,代码来源:Loggers.java

示例11: leavePublicChat

import org.jivesoftware.smack.SmackException; //导入方法依赖的package包/类
public void leavePublicChat(String chatJid) {
    MultiUserChat muc = publicChats.get(chatJid);
    try {
        if (publicChats.get(chatJid) != null) {
            muc.leave();
        }

    } catch (SmackException.NotConnectedException ex){
        Logger.logExceptionToFabric(ex);
        publicChatToLeave = chatJid;
    }
}
 
开发者ID:ukevgen,项目名称:BizareChat,代码行数:13,代码来源:QuickbloxPrivateXmppConnection.java

示例12: removeChatGuyFromContacts

import org.jivesoftware.smack.SmackException; //导入方法依赖的package包/类
private void removeChatGuyFromContacts() {
    User userNotContact = new User();
    userNotContact.setLogin(XMPPUtils.fromJIDToUserName(mChat.getJid()));
    try {
        RosterManager.getInstance().removeContact(userNotContact);
        setMenuChatNotContact();
        Toast.makeText(this, String.format(Locale.getDefault(), getString(R.string.user_removed_from_contacts),
                userNotContact.getLogin()), Toast.LENGTH_SHORT).show();
    } catch (SmackException.NotLoggedInException | InterruptedException |
            SmackException.NotConnectedException | XMPPException.XMPPErrorException |
            XmppStringprepException | SmackException.NoResponseException e) {
        e.printStackTrace();
    }
}
 
开发者ID:esl,项目名称:mangosta-android,代码行数:15,代码来源:ChatActivity.java

示例13: addChatGuyToContacts

import org.jivesoftware.smack.SmackException; //导入方法依赖的package包/类
private void addChatGuyToContacts() {
    User userContact = new User();
    userContact.setLogin(XMPPUtils.fromJIDToUserName(mChat.getJid()));
    try {
        RosterManager.getInstance().addContact(userContact);
        setMenuChatWithContact();
        Toast.makeText(this, String.format(Locale.getDefault(), getString(R.string.user_added_to_contacts),
                userContact.getLogin()), Toast.LENGTH_SHORT).show();
    } catch (SmackException.NotLoggedInException | InterruptedException | SmackException.NotConnectedException | XMPPException.XMPPErrorException | XmppStringprepException | SmackException.NoResponseException e) {
        e.printStackTrace();
    }
}
 
开发者ID:esl,项目名称:mangosta-android,代码行数:13,代码来源:ChatActivity.java

示例14: isChatWithContact

import org.jivesoftware.smack.SmackException; //导入方法依赖的package包/类
private boolean isChatWithContact() {
    try {
        HashMap<Jid, Presence.Type> buddies = RosterManager.getInstance().getContacts();
        for (Map.Entry pair : buddies.entrySet()) {
            if (mChat.getJid().equals(pair.getKey().toString())) {
                return true;
            }
        }
    } catch (SmackException.NotLoggedInException | InterruptedException | SmackException.NotConnectedException e) {
        e.printStackTrace();
    }
    return false;
}
 
开发者ID:esl,项目名称:mangosta-android,代码行数:14,代码来源:ChatActivity.java

示例15: removeContact

import org.jivesoftware.smack.SmackException; //导入方法依赖的package包/类
public void removeContact(User user)
        throws SmackException.NotLoggedInException, InterruptedException,
        SmackException.NotConnectedException, XMPPException.XMPPErrorException,
        SmackException.NoResponseException, XmppStringprepException {
    String jidString = XMPPUtils.fromUserNameToJID(user.getLogin());
    removeContact(jidString);
}
 
开发者ID:esl,项目名称:mangosta-android,代码行数:8,代码来源:RosterManager.java


注:本文中的org.jivesoftware.smack.SmackException.NotConnectedException方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。