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


Java Bind.setResource方法代码示例

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


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

示例1: parseResourceBinding

import org.jivesoftware.smack.packet.Bind; //导入方法依赖的package包/类
private static Bind parseResourceBinding(XmlPullParser parser) throws IOException,
        XmlPullParserException {
    Bind bind = new Bind();
    boolean done = false;
    while (!done) {
        int eventType = parser.next();
        if (eventType == XmlPullParser.START_TAG) {
            if (parser.getName().equals("resource")) {
                bind.setResource(parser.nextText());
            }
            else if (parser.getName().equals("jid")) {
                bind.setJid(parser.nextText());
            }
        } else if (eventType == XmlPullParser.END_TAG) {
            if (parser.getName().equals("bind")) {
                done = true;
            }
        }
    }

    return bind;
}
 
开发者ID:samuelhehe,项目名称:androidpn_enhanced_client,代码行数:23,代码来源:PacketParserUtils.java

示例2: bindResourceAndEstablishSession

import org.jivesoftware.smack.packet.Bind; //导入方法依赖的package包/类
private String bindResourceAndEstablishSession(String resource) throws XMPPException {
    // Wait until server sends response containing the <bind> element
    synchronized (this) {
        if (!resourceBinded) {
            try {
                wait(30000);
            }
            catch (InterruptedException e) {
                // Ignore
            }
        }
    }

    if (!resourceBinded) {
        // Server never offered resource binding
        throw new XMPPException("Resource binding not offered by server");
    }

    Bind bindResource = new Bind();
    bindResource.setResource(resource);

    PacketCollector collector = connection
            .createPacketCollector(new PacketIDFilter(bindResource.getPacketID()));
    // Send the packet
    connection.sendPacket(bindResource);
    // Wait up to a certain number of seconds for a response from the server.
    Bind response = (Bind) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
    collector.cancel();
    if (response == null) {
        throw new XMPPException("No response from the server.");
    }
    // If the server replied with an error, throw an exception.
    else if (response.getType() == IQ.Type.ERROR) {
        throw new XMPPException(response.getError());
    }
    String userJID = response.getJid();

    if (sessionSupported) {
        Session session = new Session();
        collector = connection.createPacketCollector(new PacketIDFilter(session.getPacketID()));
        // Send the packet
        connection.sendPacket(session);
        // Wait up to a certain number of seconds for a response from the server.
        IQ ack = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
        collector.cancel();
        if (ack == null) {
            throw new XMPPException("No response from the server.");
        }
        // If the server replied with an error, throw an exception.
        else if (ack.getType() == IQ.Type.ERROR) {
            throw new XMPPException(ack.getError());
        }
    }
    else {
        // Server never offered session establishment
        throw new XMPPException("Session establishment not offered by server");
    }
    return userJID;
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:60,代码来源:SASLAuthentication.java

示例3: bindResourceAndEstablishSession

import org.jivesoftware.smack.packet.Bind; //导入方法依赖的package包/类
private String bindResourceAndEstablishSession(String resource) throws XMPPException {
    // Wait until server sends response containing the <bind> element
    synchronized (this) {
        long endTime = System.currentTimeMillis() + 30000;
        while (!resourceBinded && (System.currentTimeMillis() < endTime)) {
            try {
                wait(Math.abs(System.currentTimeMillis() - endTime));
            }
            catch (InterruptedException e) {
                // Ignore
            }
        }
    }

    if (!resourceBinded) {
        // Server never offered resource binding
        throw new XMPPException("Resource binding not offered by server");
    }

    Bind bindResource = new Bind();
    bindResource.setResource(resource);

    PacketCollector collector = connection
            .createPacketCollector(new PacketIDFilter(bindResource.getPacketID()));
    // Send the packet
    connection.sendPacket(bindResource);
    // Wait up to a certain number of seconds for a response from the server.
    Bind response = (Bind) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
    collector.cancel();
    if (response == null) {
        throw new XMPPException("No response from the server.");
    }
    // If the server replied with an error, throw an exception.
    else if (response.getType() == IQ.Type.ERROR) {
        throw new XMPPException(response.getError());
    }
    String userJID = response.getJid();

    if (sessionSupported) {
        Session session = new Session();
        collector = connection.createPacketCollector(new PacketIDFilter(session.getPacketID()));
        // Send the packet
        connection.sendPacket(session);
        // Wait up to a certain number of seconds for a response from the server.
        IQ ack = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
        collector.cancel();
        if (ack == null) {
            throw new XMPPException("No response from the server.");
        }
        // If the server replied with an error, throw an exception.
        else if (ack.getType() == IQ.Type.ERROR) {
            throw new XMPPException(ack.getError());
        }
    }
    else {
        // Server never offered session establishment
        throw new XMPPException("Session establishment not offered by server");
    }
    return userJID;
}
 
开发者ID:samuelhehe,项目名称:androidpn_enhanced_client,代码行数:61,代码来源:SASLAuthentication.java

示例4: bindResourceAndEstablishSession

import org.jivesoftware.smack.packet.Bind; //导入方法依赖的package包/类
private String bindResourceAndEstablishSession(String resource) throws XMPPException {
    // Wait until server sends response containing the <bind> element
    synchronized (this) {
        if (!resourceBinded) {
            try {
                wait(30000);
            }
            catch (InterruptedException e) {
                // Ignore
            }
        }
    }

    if (!resourceBinded) {
        // Server never offered resource binding
        throw new XMPPException("Resource binding not offered by server");
    }

    Bind bindResource = new Bind();
    bindResource.setResource(resource);

    PacketCollector collector = connection
            .createPacketCollector(new PacketIDFilter(bindResource.getPacketID()));
    // Send the packet
    connection.sendPacket(bindResource);
    // Wait up to a certain number of seconds for a response from the server.
    Bind response = (Bind) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
    collector.cancel();
    if (response == null) {
        throw new XMPPException("No response from the server.");
    }
    // If the server replied with an error, throw an exception.
    else if (response.getType() == IQ.Type.ERROR) {
        throw new XMPPException(response.getError());
    }
    String userJID = response.getJid();

    if (sessionSupported) {
        Session session = new Session();
        collector = connection.createPacketCollector(new PacketIDFilter(session.getPacketID()));
        // Send the packet
        connection.sendPacket(session);
        // Wait up to a certain number of seconds for a response from the server.
        IQ ack = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
        collector.cancel();
        if (ack == null) {
            throw new XMPPException("No response from the server.");
        }
        // If the server replied with an error, throw an exception.
        else if (ack.getType() == IQ.Type.ERROR) {
            throw new XMPPException(ack.getError());
        }
    }
    return userJID;
}
 
开发者ID:CJC-ivotten,项目名称:androidPN-client.,代码行数:56,代码来源:SASLAuthentication.java

示例5: bindResourceAndEstablishSession

import org.jivesoftware.smack.packet.Bind; //导入方法依赖的package包/类
private String bindResourceAndEstablishSession(String resource)
		throws XMPPException {
	// Wait until server sends response containing the <bind> element
	synchronized (this) {
		if (!resourceBinded) {
			try {
				wait(30000);
			} catch (InterruptedException e) {
				// Ignore
			}
		}
	}

	if (!resourceBinded) {
		// Server never offered resource binding
		throw new XMPPException("Resource binding not offered by server");
	}

	Bind bindResource = new Bind();
	bindResource.setResource(resource);

	PacketCollector collector = connection
			.createPacketCollector(new PacketIDFilter(bindResource
					.getPacketID()));
	// Send the packet
	connection.sendPacket(bindResource);
	// Wait up to a certain number of seconds for a response from the
	// server.
	Bind response = (Bind) collector.nextResult(SmackConfiguration
			.getPacketReplyTimeout());
	collector.cancel();
	if (response == null) {
		throw new XMPPException("No response from the server.");
	}
	// If the server replied with an error, throw an exception.
	else if (response.getType() == IQ.Type.ERROR) {
		throw new XMPPException(response.getError());
	}
	String userJID = response.getJid();

	if (sessionSupported) {
		Session session = new Session();
		collector = connection.createPacketCollector(new PacketIDFilter(
				session.getPacketID()));
		// Send the packet
		connection.sendPacket(session);
		// Wait up to a certain number of seconds for a response from the
		// server.
		IQ ack = (IQ) collector.nextResult(SmackConfiguration
				.getPacketReplyTimeout());
		collector.cancel();
		if (ack == null) {
			throw new XMPPException("No response from the server.");
		}
		// If the server replied with an error, throw an exception.
		else if (ack.getType() == IQ.Type.ERROR) {
			throw new XMPPException(ack.getError());
		}
	} else {
		// Server never offered session establishment
		throw new XMPPException(
				"Session establishment not offered by server");
	}
	return userJID;
}
 
开发者ID:ikantech,项目名称:xmppsupport_v2,代码行数:66,代码来源:SASLAuthentication.java

示例6: bindResourceAndEstablishSession

import org.jivesoftware.smack.packet.Bind; //导入方法依赖的package包/类
private String bindResourceAndEstablishSession(String resource)
        throws XMPPException {
    // Wait until server sends response containing the <bind> element
    synchronized (this) {
        if (!resourceBinded) {
            try {
                wait(30000);
            } catch (InterruptedException e) {
                // Ignore
            }
        }
    }

    if (!resourceBinded) {
        // Server never offered resource binding
        throw new XMPPException("Resource binding not offered by server");
    }

    Bind bindResource = new Bind();
    bindResource.setResource(resource);

    PacketCollector collector = connection
            .createPacketCollector(new PacketIDFilter(bindResource.getID()));
    // Send the packet
    connection.sendPacket(bindResource);
    // Wait up to a certain number of seconds for a response from the
    // server.
    Bind response = (Bind) collector.nextResult(SmackConfiguration
            .getPacketReplyTimeout());
    collector.cancel();
    if (response == null) {
        throw new XMPPException("No response from the server.");
    }
    // If the server replied with an error, throw an exception.
    else if (response.getType() == IQ.Type.error) {
        throw new XMPPException(response.getError());
    }
    String userJID = response.getJid();

    if (sessionSupported) {
        Session session = new Session();
        collector = connection.createPacketCollector(new PacketIDFilter(
                session.getID()));
        // Send the packet
        connection.sendPacket(session);
        // Wait up to a certain number of seconds for a response from the
        // server.
        IQ ack = (IQ) collector.nextResult(SmackConfiguration
                .getPacketReplyTimeout());
        collector.cancel();
        if (ack == null) {
            throw new XMPPException("No response from the server.");
        }
        // If the server replied with an error, throw an exception.
        else if (ack.getType() == IQ.Type.error) {
            throw new XMPPException(ack.getError());
        }
    }
    return userJID;
}
 
开发者ID:abmargb,项目名称:jamppa,代码行数:61,代码来源:SASLAuthentication.java


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