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


Java CloseCodes.GOING_AWAY属性代码示例

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


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

示例1: destroy

/**
 * Cleans up the resources still in use by WebSocket sessions created from
 * this container. This includes closing sessions and cancelling
 * {@link Future}s associated with blocking read/writes.
 */
public void destroy() {
    CloseReason cr = new CloseReason(
            CloseCodes.GOING_AWAY, sm.getString("wsWebSocketContainer.shutdown"));

    for (WsSession session : sessions.keySet()) {
        try {
            session.close(cr);
        } catch (IOException ioe) {
            log.debug(sm.getString(
                    "wsWebSocketContainer.sessionCloseFail", session.getId()), ioe);
        }
    }

    // Only unregister with AsyncChannelGroupUtil if this instance
    // registered with it
    if (asynchronousChannelGroup != null) {
        synchronized (asynchronousChannelGroupLock) {
            if (asynchronousChannelGroup != null) {
                AsyncChannelGroupUtil.unregister();
                asynchronousChannelGroup = null;
            }
        }
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:29,代码来源:WsWebSocketContainer.java

示例2: destroy

/**
 * Cleans up the resources still in use by WebSocket sessions created from
 * this container. This includes closing sessions and cancelling
 * {@link Future}s associated with blocking read/writes.
 */
public void destroy() {
	CloseReason cr = new CloseReason(CloseCodes.GOING_AWAY, sm.getString("wsWebSocketContainer.shutdown"));

	for (WsSession session : sessions.keySet()) {
		try {
			session.close(cr);
		} catch (IOException ioe) {
			log.debug(sm.getString("wsWebSocketContainer.sessionCloseFail", session.getId()), ioe);
		}
	}

	// Only unregister with AsyncChannelGroupUtil if this instance
	// registered with it
	if (asynchronousChannelGroup != null) {
		synchronized (asynchronousChannelGroupLock) {
			if (asynchronousChannelGroup != null) {
				AsyncChannelGroupUtil.unregister();
				asynchronousChannelGroup = null;
			}
		}
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:27,代码来源:WsWebSocketContainer.java

示例3: onClose

@Test
public void onClose() {
	final Session session = mock(Session.class);
	when(session.getId()).thenReturn("sessionId");
	final CloseReason reason = new CloseReason(CloseCodes.GOING_AWAY, "oooh");
	when(this.sessionEvent.select(OnClose.Literal.onClose())).thenReturn(this.sessionEvent);

	this.endpoint.onClose(session, reason);

	verify(session).getId();
	verify(session).getUserPrincipal();
	verify(this.log).info("WebSocket connection closed. [id={},principle={},code={},reason={}]", "sessionId", null, reason.getCloseCode(), reason.getReasonPhrase());
	verify(this.beanManager).getExtension(Extension.class);
	verify(this.registry).unregister(session);
	verify(this.sessionEvent).select(OnClose.Literal.onClose());
	verify(this.sessionEvent).fire(session);
	verifyNoMoreInteractions(session);
}
 
开发者ID:dansiviter,项目名称:cito,代码行数:18,代码来源:AbstractEndpointTest.java

示例4: destroy

/**
 * Cleans up the resources still in use by WebSocket sessions created from
 * this container. This includes closing sessions and cancelling
 * {@link Future}s associated with blocking read/writes.
 */
public void destroy() {
    CloseReason cr = new CloseReason(
            CloseCodes.GOING_AWAY, sm.getString("wsWebSocketContainer.shutdown"));

    for (WsSession session : sessions.keySet()) {
        try {
            session.close(cr);
        } catch (IOException ioe) {
            log.debug(sm.getString(
                    "wsWebSocketContainer.sessionCloseFail", session.getId()), ioe);
        }
    }
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:18,代码来源:WsWebSocketContainer.java

示例5: getCloseCode

static CloseCode getCloseCode(int code) {
    if (code > 2999 && code < 5000) {
        return CloseCodes.getCloseCode(code);
    }
    switch (code) {
        case 1000:
            return CloseCodes.NORMAL_CLOSURE;
        case 1001:
            return CloseCodes.GOING_AWAY;
        case 1002:
            return CloseCodes.PROTOCOL_ERROR;
        case 1003:
            return CloseCodes.CANNOT_ACCEPT;
        case 1004:
            // Should not be used in a close frame
            // return CloseCodes.RESERVED;
            return CloseCodes.PROTOCOL_ERROR;
        case 1005:
            // Should not be used in a close frame
            // return CloseCodes.NO_STATUS_CODE;
            return CloseCodes.PROTOCOL_ERROR;
        case 1006:
            // Should not be used in a close frame
            // return CloseCodes.CLOSED_ABNORMALLY;
            return CloseCodes.PROTOCOL_ERROR;
        case 1007:
            return CloseCodes.NOT_CONSISTENT;
        case 1008:
            return CloseCodes.VIOLATED_POLICY;
        case 1009:
            return CloseCodes.TOO_BIG;
        case 1010:
            return CloseCodes.NO_EXTENSION;
        case 1011:
            return CloseCodes.UNEXPECTED_CONDITION;
        case 1012:
            // Not in RFC6455
            // return CloseCodes.SERVICE_RESTART;
            return CloseCodes.PROTOCOL_ERROR;
        case 1013:
            // Not in RFC6455
            // return CloseCodes.TRY_AGAIN_LATER;
            return CloseCodes.PROTOCOL_ERROR;
        case 1015:
            // Should not be used in a close frame
            // return CloseCodes.TLS_HANDSHAKE_FAILURE;
            return CloseCodes.PROTOCOL_ERROR;
        default:
            return CloseCodes.PROTOCOL_ERROR;
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:51,代码来源:Util.java

示例6: getCloseCode

static CloseCode getCloseCode(int code) {
	if (code > 2999 && code < 5000) {
		return CloseCodes.getCloseCode(code);
	}
	switch (code) {
	case 1000:
		return CloseCodes.NORMAL_CLOSURE;
	case 1001:
		return CloseCodes.GOING_AWAY;
	case 1002:
		return CloseCodes.PROTOCOL_ERROR;
	case 1003:
		return CloseCodes.CANNOT_ACCEPT;
	case 1004:
		// Should not be used in a close frame
		// return CloseCodes.RESERVED;
		return CloseCodes.PROTOCOL_ERROR;
	case 1005:
		// Should not be used in a close frame
		// return CloseCodes.NO_STATUS_CODE;
		return CloseCodes.PROTOCOL_ERROR;
	case 1006:
		// Should not be used in a close frame
		// return CloseCodes.CLOSED_ABNORMALLY;
		return CloseCodes.PROTOCOL_ERROR;
	case 1007:
		return CloseCodes.NOT_CONSISTENT;
	case 1008:
		return CloseCodes.VIOLATED_POLICY;
	case 1009:
		return CloseCodes.TOO_BIG;
	case 1010:
		return CloseCodes.NO_EXTENSION;
	case 1011:
		return CloseCodes.UNEXPECTED_CONDITION;
	case 1012:
		// Not in RFC6455
		// return CloseCodes.SERVICE_RESTART;
		return CloseCodes.PROTOCOL_ERROR;
	case 1013:
		// Not in RFC6455
		// return CloseCodes.TRY_AGAIN_LATER;
		return CloseCodes.PROTOCOL_ERROR;
	case 1015:
		// Should not be used in a close frame
		// return CloseCodes.TLS_HANDSHAKE_FAILURE;
		return CloseCodes.PROTOCOL_ERROR;
	default:
		return CloseCodes.PROTOCOL_ERROR;
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:51,代码来源:Util.java

示例7: getCloseCode

static CloseCode getCloseCode(int code) {
    if (code > 2999 && code < 5000) {
        return CloseCodes.NORMAL_CLOSURE;
    }
    switch (code) {
        case 1000:
            return CloseCodes.NORMAL_CLOSURE;
        case 1001:
            return CloseCodes.GOING_AWAY;
        case 1002:
            return CloseCodes.PROTOCOL_ERROR;
        case 1003:
            return CloseCodes.CANNOT_ACCEPT;
        case 1004:
            // Should not be used in a close frame
            // return CloseCodes.RESERVED;
            return CloseCodes.PROTOCOL_ERROR;
        case 1005:
            // Should not be used in a close frame
            // return CloseCodes.NO_STATUS_CODE;
            return CloseCodes.PROTOCOL_ERROR;
        case 1006:
            // Should not be used in a close frame
            // return CloseCodes.CLOSED_ABNORMALLY;
            return CloseCodes.PROTOCOL_ERROR;
        case 1007:
            return CloseCodes.NOT_CONSISTENT;
        case 1008:
            return CloseCodes.VIOLATED_POLICY;
        case 1009:
            return CloseCodes.TOO_BIG;
        case 1010:
            return CloseCodes.NO_EXTENSION;
        case 1011:
            return CloseCodes.UNEXPECTED_CONDITION;
        case 1012:
            // Not in RFC6455
            // return CloseCodes.SERVICE_RESTART;
            return CloseCodes.PROTOCOL_ERROR;
        case 1013:
            // Not in RFC6455
            // return CloseCodes.TRY_AGAIN_LATER;
            return CloseCodes.PROTOCOL_ERROR;
        case 1015:
            // Should not be used in a close frame
            // return CloseCodes.TLS_HANDSHAKE_FAILURE;
            return CloseCodes.PROTOCOL_ERROR;
        default:
            return CloseCodes.PROTOCOL_ERROR;
    }
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:51,代码来源:Util.java


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