本文整理汇总了Java中org.jivesoftware.smack.SmackException.NoResponseException方法的典型用法代码示例。如果您正苦于以下问题:Java SmackException.NoResponseException方法的具体用法?Java SmackException.NoResponseException怎么用?Java SmackException.NoResponseException使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.smack.SmackException
的用法示例。
在下文中一共展示了SmackException.NoResponseException方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: waitResponse
import org.jivesoftware.smack.SmackException; //导入方法依赖的package包/类
private SampleResult waitResponse(SampleResult res, String recipient) throws InterruptedException, SmackException {
long time = 0;
do {
Iterator<Message> packets = responseMessages.iterator();
Thread.sleep(conn.getPacketReplyTimeout() / 100); // optimistic
while (packets.hasNext()) {
Packet packet = packets.next();
Message response = (Message) packet;
if (XmppStringUtils.parseBareAddress(response.getFrom()).equals(recipient)) {
packets.remove();
res.setResponseData(response.toXML().toString().getBytes());
if (response.getError() != null) {
res.setSuccessful(false);
res.setResponseCode("500");
res.setResponseMessage(response.getError().toString());
}
return res;
}
}
time += conn.getPacketReplyTimeout() / 10;
Thread.sleep(conn.getPacketReplyTimeout() / 10);
} while (time < conn.getPacketReplyTimeout());
throw new SmackException.NoResponseException();
}
示例2: 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);
}
}
示例3: sendBlogPostComment
import org.jivesoftware.smack.SmackException; //导入方法依赖的package包/类
public BlogPostComment sendBlogPostComment(String content, BlogPost blogPost)
throws SmackException.NotConnectedException, InterruptedException,
XMPPException.XMPPErrorException, SmackException.NoResponseException {
Jid jid = XMPPSession.getInstance().getUser().asEntityBareJid();
String userName = XMPPUtils.fromJIDToUserName(jid.toString());
Jid pubSubServiceJid = XMPPSession.getInstance().getPubSubService();
// create stanza
PublishCommentExtension publishCommentExtension = new PublishCommentExtension(blogPost.getId(), userName, jid, content, new Date());
PubSub publishCommentPubSub = PubSub.createPubsubPacket(pubSubServiceJid, IQ.Type.set, publishCommentExtension, null);
// send stanza
XMPPSession.getInstance().sendStanza(publishCommentPubSub);
return new BlogPostComment(publishCommentExtension.getId(),
blogPost.getId(),
content,
userName,
jid.toString(),
publishCommentExtension.getPublished());
}
示例4: 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);
}
示例5: 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();
}
}
示例6: removeContact
import org.jivesoftware.smack.SmackException; //导入方法依赖的package包/类
public void removeContact(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);
roster.removeEntry(roster.getEntry(jid));
Presence presence = new Presence(Presence.Type.unsubscribe);
presence.setTo(JidCreate.from(jidString));
XMPPSession.getInstance().sendStanza(presence);
}
示例7: claimButtonClicked
import org.jivesoftware.smack.SmackException; //导入方法依赖的package包/类
private void claimButtonClicked(final Thing thing) {
final XMPPTCPConnection connection = mXmppManger.getXmppConnection();
if (connection == null) {
showInGui("Not connection available");
return;
}
if (!connection.isAuthenticated()) {
showInGui("Connection not authenticated");
return;
}
IoTDiscoveryManager ioTDiscoveryManager = IoTDiscoveryManager.getInstanceFor(connection);
IoTClaimed iotClaimed;
try {
iotClaimed = ioTDiscoveryManager.claimThing(mRegistry, thing.getMetaTags(), true);
} catch (SmackException.NoResponseException | XMPPException.XMPPErrorException | SmackException.NotConnectedException | InterruptedException e) {
showInGui("Could not claim because " + e);
LOGGER.log(Level.WARNING, "Could not register", e);
return;
}
EntityBareJid claimedJid = iotClaimed.getJid().asEntityBareJidIfPossible();
if (claimedJid == null) {
throw new IllegalStateException();
}
Settings settings = Settings.getInstance(this);
settings.setClaimedJid(claimedJid);
showInGui("Thing " + claimedJid + " claimed.");
runOnUiThread(() -> {
finish();
});
}
示例8: performReadOut
import org.jivesoftware.smack.SmackException; //导入方法依赖的package包/类
private void performReadOut() {
XMPPTCPConnection connection = mXmppManager.getXmppConnection();
EntityFullJid fullThingJid = mXmppManager.getFullThingJidOrNotify();
if (fullThingJid == null) return;
LOGGER.info("Requesting read out from " + fullThingJid);
IoTDataManager iotDataManager = IoTDataManager.getInstanceFor(connection);
final List<IoTFieldsExtension> res;
try {
res = iotDataManager.requestMomentaryValuesReadOut(fullThingJid);
} catch (SmackException.NoResponseException | XMPPErrorException | SmackException.NotConnectedException |InterruptedException e) {
mXmppManager.withMainActivity((ma) -> Toast.makeText(mContext, "Could not perform read out: " + e, Toast.LENGTH_LONG).show());
LOGGER.log(Level.WARNING, "Could not perform read out", e);
return;
}
final List<? extends IoTDataField> dataFields = res.get(0).getNodes().get(0).getTimestampElements().get(0).getDataFields();
mXmppManager.withMainActivity((ma) -> {
ma.mIotSensorsLinearLayout.removeAllViews();
for (IoTDataField field : dataFields) {
IotSensorView iotSensorView = new IotSensorView(ma, field.getName(), field.getValueString());
ma.mIotSensorsLinearLayout.addView(iotSensorView);
}
});
}
示例9: 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();
}
}
示例10: 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();
}
}
示例11: getSubject
import org.jivesoftware.smack.SmackException; //导入方法依赖的package包/类
private void getSubject(Chat chatRoom) {
try {
MultiUserChatLight multiUserChatLight = XMPPSession.getInstance().getMUCLightManager().getMultiUserChatLight(JidCreate.from(chatRoom.getJid()).asEntityBareJidIfPossible());
MUCLightRoomConfiguration configuration = multiUserChatLight.getConfiguration();
chatRoom.setSubject(configuration.getSubject());
} catch (XmppStringprepException | SmackException.NoResponseException | XMPPException.XMPPErrorException | SmackException.NotConnectedException | InterruptedException e) {
e.printStackTrace();
}
}
示例12: loadMUCLightMembers
import org.jivesoftware.smack.SmackException; //导入方法依赖的package包/类
public List<String> loadMUCLightMembers(String roomJid) throws XmppStringprepException, SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException {
MultiUserChatLightManager multiUserChatLightManager = MultiUserChatLightManager.getInstanceFor(XMPPSession.getInstance().getXMPPConnection());
MultiUserChatLight multiUserChatLight = multiUserChatLightManager.getMultiUserChatLight(JidCreate.from(roomJid).asEntityBareJidIfPossible());
HashMap<Jid, MUCLightAffiliation> occupants = multiUserChatLight.getAffiliations();
List<String> jids = new ArrayList<>();
for (Map.Entry<Jid, MUCLightAffiliation> pair : occupants.entrySet()) {
Jid jid = pair.getKey();
if (jid != null) {
jids.add(jid.toString());
}
}
return jids;
}
示例13: addToMUCLight
import org.jivesoftware.smack.SmackException; //导入方法依赖的package包/类
public void addToMUCLight(User user, String chatJID) {
MultiUserChatLightManager multiUserChatLightManager = XMPPSession.getInstance().getMUCLightManager();
try {
MultiUserChatLight mucLight = multiUserChatLightManager.getMultiUserChatLight(JidCreate.from(chatJID).asEntityBareJidIfPossible());
Jid jid = JidCreate.from(XMPPUtils.fromUserNameToJID(user.getLogin()));
HashMap<Jid, MUCLightAffiliation> affiliations = new HashMap<>();
affiliations.put(jid, MUCLightAffiliation.member);
mucLight.changeAffiliations(affiliations);
} catch (XmppStringprepException | InterruptedException | SmackException.NotConnectedException | SmackException.NoResponseException | XMPPException.XMPPErrorException e) {
e.printStackTrace();
}
}
示例14: removeFromMUCLight
import org.jivesoftware.smack.SmackException; //导入方法依赖的package包/类
public void removeFromMUCLight(User user, String chatJID) {
MultiUserChatLightManager multiUserChatLightManager = XMPPSession.getInstance().getMUCLightManager();
try {
MultiUserChatLight mucLight = multiUserChatLightManager.getMultiUserChatLight(JidCreate.from(chatJID).asEntityBareJidIfPossible());
Jid jid = JidCreate.from(XMPPUtils.fromUserNameToJID(user.getLogin()));
HashMap<Jid, MUCLightAffiliation> affiliations = new HashMap<>();
affiliations.put(jid, MUCLightAffiliation.none);
mucLight.changeAffiliations(affiliations);
} catch (XmppStringprepException | InterruptedException | SmackException.NotConnectedException | SmackException.NoResponseException | XMPPException.XMPPErrorException e) {
e.printStackTrace();
}
}
示例15: getXOAUTHTokens
import org.jivesoftware.smack.SmackException; //导入方法依赖的package包/类
public void getXOAUTHTokens() {
TBRManager tbrManager = TBRManager.getInstanceFor(getXMPPConnection());
try {
Preferences preferences = Preferences.getInstance();
TBRTokens tbrTokens = tbrManager.getTokens();
preferences.setXmppOauthAccessToken(tbrTokens.getAccessToken());
preferences.setXmppOauthRefreshToken(tbrTokens.getRefreshToken());
} catch (SmackException.NoResponseException | XMPPException.XMPPErrorException | InterruptedException | SmackException.NotConnectedException e) {
e.printStackTrace();
}
}