本文整理汇总了Java中org.jivesoftware.smack.packet.Registration.setRemove方法的典型用法代码示例。如果您正苦于以下问题:Java Registration.setRemove方法的具体用法?Java Registration.setRemove怎么用?Java Registration.setRemove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.smack.packet.Registration
的用法示例。
在下文中一共展示了Registration.setRemove方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deleteAccount
import org.jivesoftware.smack.packet.Registration; //导入方法依赖的package包/类
/**
* Deletes the currently logged-in account from the server. This operation can only
* be performed after a successful login operation has been completed. Not all servers
* support deleting accounts; an XMPPException will be thrown when that is the case.
*
* @throws IllegalStateException if not currently logged-in to the server.
* @throws XMPPException if an error occurs when deleting the account.
*/
public void deleteAccount() throws XMPPException {
if (!connection.isAuthenticated()) {
throw new IllegalStateException("Must be logged in to delete a account.");
}
Registration reg = new Registration();
reg.setType(IQ.Type.SET);
reg.setTo(connection.getServiceName());
// To delete an account, we set remove to true
reg.setRemove(true);
PacketFilter filter = new AndFilter(new PacketIDFilter(reg.getPacketID()),
new PacketTypeFilter(IQ.class));
PacketCollector collector = connection.createPacketCollector(filter);
connection.sendPacket(reg);
IQ result = (IQ)collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
// Stop queuing results
collector.cancel();
if (result == null) {
throw new XMPPException("No response from server.");
}
else if (result.getType() == IQ.Type.ERROR) {
throw new XMPPException(result.getError());
}
}
示例2: deleteAccount
import org.jivesoftware.smack.packet.Registration; //导入方法依赖的package包/类
/**
* Deletes the currently logged-in account from the server. This operation can only
* be performed after a successful login operation has been completed. Not all servers
* support deleting accounts; an XMPPException will be thrown when that is the case.
*
* @throws IllegalStateException if not currently logged-in to the server.
* @throws org.jivesoftware.smack.XMPPException if an error occurs when deleting the account.
*/
public void deleteAccount() throws XMPPException {
if (!connection.isAuthenticated()) {
throw new IllegalStateException("Must be logged in to delete a account.");
}
Registration reg = new Registration();
reg.setType(IQ.Type.SET);
reg.setTo(connection.getServiceName());
// To delete an account, we set remove to true
reg.setRemove(true);
PacketFilter filter = new AndFilter(new PacketIDFilter(reg.getPacketID()),
new PacketTypeFilter(IQ.class));
PacketCollector collector = connection.createPacketCollector(filter);
connection.sendPacket(reg);
IQ result = (IQ)collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
// Stop queuing results
collector.cancel();
if (result == null) {
throw new XMPPException("No response from server.");
}
else if (result.getType() == IQ.Type.ERROR) {
throw new XMPPException(result.getError());
}
}
示例3: unregister
import org.jivesoftware.smack.packet.Registration; //导入方法依赖的package包/类
/**
* This method removes an existing registration from this gateway
* @throws XMPPException
*/
public void unregister() throws XMPPException{
Registration register = new Registration();
register.setFrom(connection.getUser());
register.setTo(entityJID);
register.setType(IQ.Type.SET);
register.setRemove(true);
PacketCollector resultCollector =
connection.createPacketCollector(new PacketIDFilter(register.getPacketID()));
connection.sendPacket(register);
Packet result = resultCollector.nextResult(SmackConfiguration.getPacketReplyTimeout());
resultCollector.cancel();
if(result!=null && result instanceof IQ){
IQ resultIQ = (IQ)result;
if(resultIQ.getError()!=null){
throw new XMPPException(resultIQ.getError());
}
if(resultIQ.getType()==IQ.Type.ERROR){
throw new XMPPException(resultIQ.getError());
}
RosterEntry gatewayEntry = roster.getEntry(entityJID);
roster.removeEntry(gatewayEntry);
}
else{
throw new XMPPException("Packet reply timeout");
}
}
示例4: unregister
import org.jivesoftware.smack.packet.Registration; //导入方法依赖的package包/类
/**
* This method removes an existing registration from this gateway
*
* @throws XMPPException
*/
public void unregister() throws XMPPException {
Registration register = new Registration();
register.setFrom(connection.getUser());
register.setTo(entityJID);
register.setType(IQ.Type.SET);
register.setRemove(true);
PacketCollector resultCollector = connection
.createPacketCollector(new PacketIDFilter(register
.getPacketID()));
connection.sendPacket(register);
Packet result = resultCollector.nextResult(SmackConfiguration
.getPacketReplyTimeout());
resultCollector.cancel();
if (result != null && result instanceof IQ) {
IQ resultIQ = (IQ) result;
if (resultIQ.getError() != null) {
throw new XMPPException(resultIQ.getError());
}
if (resultIQ.getType() == IQ.Type.ERROR) {
throw new XMPPException(resultIQ.getError());
}
RosterEntry gatewayEntry = roster.getEntry(entityJID);
roster.removeEntry(gatewayEntry);
} else {
throw new XMPPException("Packet reply timeout");
}
}