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


Java Type类代码示例

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

示例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;
}
 
开发者ID:abmargb,项目名称:jamppa,代码行数:25,代码来源:XMPPUtils.java

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

示例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);
}
 
开发者ID:abmargb,项目名称:jamppa,代码行数:13,代码来源:XMPPUtils.java

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

示例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);
}
 
开发者ID:abmargb,项目名称:jamppa,代码行数:15,代码来源:XMPPUtils.java


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