本文整理汇总了Java中org.jivesoftware.smack.packet.Bind.getType方法的典型用法代码示例。如果您正苦于以下问题:Java Bind.getType方法的具体用法?Java Bind.getType怎么用?Java Bind.getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.smack.packet.Bind
的用法示例。
在下文中一共展示了Bind.getType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例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) {
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;
}
示例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) {
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;
}
示例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());
}
} else {
// Server never offered session establishment
throw new XMPPException(
"Session establishment not offered by server");
}
return userJID;
}
示例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.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;
}