本文整理汇总了Java中org.xmpp.packet.PacketError.Type类的典型用法代码示例。如果您正苦于以下问题:Java Type类的具体用法?Java Type怎么用?Java Type使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Type类属于org.xmpp.packet.PacketError包,在下文中一共展示了Type类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: notifyConnectionError
import org.xmpp.packet.PacketError.Type; //导入依赖的package包/类
/**
* Sends out a notification that there was an error with the connection and
* closes the connection. Also prints the stack trace of the given exception
*
* @param e
* the exception that causes the connection close event.
*/
synchronized void notifyConnectionError(Exception e) {
// Listeners were already notified of the exception, return right here.
if ((packetReader == null || packetReader.done)
&& (packetWriter == null || packetWriter.done))
return;
if (packetReader != null)
packetReader.done = true;
if (packetWriter != null)
packetWriter.done = true;
// Closes the connection temporary. A reconnection is possible
shutdown(new Presence(Presence.Type.unavailable));
// Notify connection listeners of the error.
for (ConnectionListener listener : getConnectionListeners()) {
try {
listener.connectionClosedOnError(e);
} catch (Exception e2) {
// Catch and print any exception so we can recover
// from a faulty listener
e2.printStackTrace();
}
}
}
示例2: createErrorResponse
import org.xmpp.packet.PacketError.Type; //导入依赖的package包/类
/**
* Creates an error response for a given IQ request.
*
* @param request
* @param message
* @param condition
* @param type
* @return
*/
public static IQ createErrorResponse(final IQ request,
final String message, Condition condition, Type type) {
final IQ result = request.createCopy();
result.setID(request.getID());
result.setFrom(request.getTo());
result.setTo(request.getFrom());
PacketError e = new PacketError(condition, type);
if (message != null) {
e.setText(message);
}
result.setError(e);
return result;
}
示例3: initReaderAndWriter
import org.xmpp.packet.PacketError.Type; //导入依赖的package包/类
private void initReaderAndWriter() throws XMPPException {
try {
if (compressionHandler == null) {
reader = new BufferedReader(new InputStreamReader(
socket.getInputStream(), "UTF-8"));
writer = new BufferedWriter(new OutputStreamWriter(
socket.getOutputStream(), "UTF-8"));
} else {
try {
OutputStream os = compressionHandler.getOutputStream(socket
.getOutputStream());
writer = new BufferedWriter(new OutputStreamWriter(os,
"UTF-8"));
InputStream is = compressionHandler.getInputStream(socket
.getInputStream());
reader = new BufferedReader(new InputStreamReader(is,
"UTF-8"));
} catch (Exception e) {
e.printStackTrace();
compressionHandler = null;
reader = new BufferedReader(new InputStreamReader(
socket.getInputStream(), "UTF-8"));
writer = new BufferedWriter(new OutputStreamWriter(
socket.getOutputStream(), "UTF-8"));
}
}
} catch (IOException ioe) {
throw new XMPPException(
"XMPPError establishing connection with server.",
new PacketError(Condition.internal_server_error,
Type.cancel,
"XMPPError establishing connection with server."),
ioe);
}
// If debugging is enabled, we open a window and write out all network
// traffic.
initDebugger();
}
示例4: error
import org.xmpp.packet.PacketError.Type; //导入依赖的package包/类
/**
* @param iq
* @param errorMessage
* @param logger
* @return
*/
public static IQ error(IQ iq, String errorMessage, Exception e,
Logger logger) {
logger.error(errorMessage, e);
return XMPPUtils.createErrorResponse(iq, errorMessage,
Condition.bad_request, Type.modify);
}
示例5: setUp
import org.xmpp.packet.PacketError.Type; //导入依赖的package包/类
/**
* Initialize the used packet-errors.
*/
@Before
public void setUp() {
stanzaError = new PacketError(Condition.not_acceptable);
applicationError = new PacketError(
Condition.undefined_condition,
Type.modify,
ERROR_TEXT,
"en");
}
示例6: errorRSM
import org.xmpp.packet.PacketError.Type; //导入依赖的package包/类
/**
* Logs the RSM page not found error and returns an IQ error response
*
* @param iq
* @param errorMessage
* @param logger
* @return
*/
public static IQ errorRSM(IQ iq, Logger logger) {
String rsmMessage = "RSM: Page Not Found";
logger.error(rsmMessage + " " + iq);
return XMPPUtils.createErrorResponse(iq, rsmMessage,
Condition.item_not_found, Type.cancel);
}