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


Java SelectableChannel.close方法代码示例

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


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

示例1: handleIOException

import java.nio.channels.SelectableChannel; //导入方法依赖的package包/类
private void handleIOException( SelectionKey key, WebSocket conn, IOException ex ) {
	// onWebsocketError( conn, ex );// conn may be null here
	if( conn != null ) {
		conn.closeConnection( CloseFrame.ABNORMAL_CLOSE, ex.getMessage() );
	} else if( key != null ) {
		SelectableChannel channel = key.channel();
		if( channel != null && channel.isOpen() ) { // this could be the case if the IOException ex is a SSLException
			try {
				channel.close();
			} catch ( IOException e ) {
				// there is nothing that must be done here
			}
			if( WebSocketImpl.DEBUG )
				System.out.println( "Connection closed because of" + ex );
		}
	}
}
 
开发者ID:LDLN,项目名称:Responder-Android,代码行数:18,代码来源:WebSocketServer.java

示例2: handleIOException

import java.nio.channels.SelectableChannel; //导入方法依赖的package包/类
private void handleIOException(SelectionKey key, WebSocket conn, IOException ex) {
    // onWebsocketError( conn, ex );// conn may be null here
    if (conn != null) {
        conn.closeConnection(CloseFrame.ABNORMAL_CLOSE, ex.getMessage());
    } else if (key != null) {
        SelectableChannel channel = key.channel();
        if (channel != null && channel.isOpen()) { // this could be the case if the IOException ex is a SSLException
            try {
                channel.close();
            } catch (IOException e) {
                // there is nothing that must be done here
            }
            if (WebSocketImpl.DEBUG) {
                System.out.println("Connection closed because of" + ex);
            }
        }
    }
}
 
开发者ID:GloriousEggroll,项目名称:quorrabot,代码行数:19,代码来源:WebSocketServer.java

示例3: handleIOException

import java.nio.channels.SelectableChannel; //导入方法依赖的package包/类
private void handleIOException(SelectionKey key, WebSocket conn, IOException ex) {
    onWebsocketError(conn, ex);
    if (conn != null) {
        conn.closeConnection(CloseFrame.ABNORMAL_CLOSE, ex.getMessage());
    } else if (key != null) {
        SelectableChannel channel = key.channel();
        if (channel != null && channel.isOpen()) {
            try {
                channel.close();
            } catch (IOException e) {
            }
            if (WebSocketImpl.DEBUG) {
                System.out.println("Connection closed because of" + ex);
            }
        }
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:18,代码来源:WebSocketServer.java

示例4: clearDeferredRegistrations

import java.nio.channels.SelectableChannel; //导入方法依赖的package包/类
private void clearDeferredRegistrations() {
    synchronized (deferredRegistrations) {
        int deferredListSize = deferredRegistrations.size();
        if (orb.transportDebugFlag) {
            dprint(".clearDeferredRegistrations:deferred list size == " + deferredListSize);
        }
        for (int i = 0; i < deferredListSize; i++) {
            EventHandler eventHandler =
                (EventHandler)deferredRegistrations.get(i);
            if (orb.transportDebugFlag) {
                dprint(".clearDeferredRegistrations: " + eventHandler);
            }
            SelectableChannel channel = eventHandler.getChannel();
            SelectionKey selectionKey = null;

            try {
                if (orb.transportDebugFlag) {
                    dprint(".clearDeferredRegistrations:close channel == "
                            + channel);
                    dprint(".clearDeferredRegistrations:close channel class == "
                            + channel.getClass().getName());
                }
                channel.close();
                selectionKey = eventHandler.getSelectionKey();
                if (selectionKey != null) {
                    selectionKey.cancel();
                    selectionKey.attach(null);
                }
            } catch (IOException ioEx) {
                if (orb.transportDebugFlag) {
                    dprint(".clearDeferredRegistrations: ", ioEx);
                }
            }
        }
        deferredRegistrations.clear();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:38,代码来源:SelectorImpl.java


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