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


Java Registration.setRemove方法代码示例

本文整理汇总了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());
    }
}
 
开发者ID:samuelhehe,项目名称:androidpn_enhanced_client,代码行数:32,代码来源:AccountManager.java

示例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());
    }
}
 
开发者ID:msdx,项目名称:AndroidPNClient,代码行数:32,代码来源:AccountManager.java

示例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");
	}
}
 
开发者ID:CJC-ivotten,项目名称:androidPN-client.,代码行数:31,代码来源:Gateway.java

示例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");
	}
}
 
开发者ID:ikantech,项目名称:xmppsupport_v2,代码行数:33,代码来源:Gateway.java


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