本文整理汇总了Java中org.eclipse.jetty.websocket.api.annotations.OnWebSocketClose类的典型用法代码示例。如果您正苦于以下问题:Java OnWebSocketClose类的具体用法?Java OnWebSocketClose怎么用?Java OnWebSocketClose使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OnWebSocketClose类属于org.eclipse.jetty.websocket.api.annotations包,在下文中一共展示了OnWebSocketClose类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onClose
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketClose; //导入依赖的package包/类
@OnWebSocketClose
public void onClose(int statusCode, String reason) {
synchronized (state) {
logger.debug("[{}] Websocket connection in state {} closed with code {} reason : {}", debugId, state,
statusCode, reason);
stopKeepAlive();
if (state == ClientState.CLOSING) {
session = null;
} else if (state != ClientState.IDLE) {
LxOfflineReason reasonCode;
if (statusCode == 1001) {
reasonCode = LxOfflineReason.IDLE_TIMEOUT;
} else if (statusCode == 4003) {
reasonCode = LxOfflineReason.TOO_MANY_FAILED_LOGIN_ATTEMPTS;
} else {
reasonCode = LxOfflineReason.COMMUNICATION_ERROR;
}
notifyMaster(EventType.SERVER_OFFLINE, reasonCode, reason);
}
setClientState(ClientState.IDLE);
}
}
示例2: onClose
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketClose; //导入依赖的package包/类
@OnWebSocketClose
public void onClose(int statusCode, String reason) {
if (statusCode != 1000) {
log.error("Disconnect " + statusCode + ": " + reason);
logMessage.append(" - WebSocket conection closed unexpectedly by the server: [").append(statusCode).append("] ").append(reason).append("\n");
error = statusCode;
} else {
logMessage.append(" - WebSocket conection has been successfully closed by the server").append("\n");
log.debug("Disconnect " + statusCode + ": " + reason);
}
//Notify connection opening and closing latches of the closed connection
openLatch.countDown();
closeLatch.countDown();
connectedLatch.countDown();
connected = false;
}
示例3: onClose
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketClose; //导入依赖的package包/类
/**
* WebSocket session has been closed
*
* @param statusCode Status code
* @param reason Reason message
*/
@OnWebSocketClose
public void onClose(int statusCode, String reason) {
lock.lock();
try {
if (session != null) {
if ((Peers.communicationLoggingMask & Peers.LOGGING_MASK_200_RESPONSES) != 0) {
Logger.logDebugMessage(String.format("%s WebSocket connection with %s closed",
peerServlet != null ? "Inbound" : "Outbound",
session.getRemoteAddress().getHostString()));
}
session = null;
}
SocketException exc = new SocketException("WebSocket connection closed");
Set<Map.Entry<Long, PostRequest>> requests = requestMap.entrySet();
requests.forEach((entry) -> entry.getValue().complete(exc));
requestMap.clear();
} finally {
lock.unlock();
}
}
示例4: onClose
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketClose; //导入依赖的package包/类
@OnWebSocketClose
public void onClose(int statusCode, String reason) {
System.out.println("WebSocket client: connection closed. Status :" + statusCode + ". Reason: " + reason);
session.close();
this.session = null;
connected = false;
receivingData = false;
receivingLeapData = false;
lastMsg = "";
lastFrame = null;
controller = null;
////////////////////////////////////////////////////////////////////////////////////
// Status code 1000: Normal closure;
// the connection successfully completed whatever purpose for which it was created.
////////////////////////////////////////////////////////////////////////////////////
if (statusCode > 1000 && statusCode < 1016) {
sessionFailed = true;
}
}
示例5: onClose
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketClose; //导入依赖的package包/类
@OnWebSocketClose
public void onClose(int statusCode, String reason) {
if (statusCode != 1000) {
log.error("Disconnect " + statusCode + ": " + reason);
logMessage.append(" - WebSocket conection closed unexpectedly by the server: [").append(statusCode).append("] ").append(reason).append("\n");
error = statusCode;
} else {
logMessage.append(" - WebSocket conection has been successfully closed by the server").append("\n");
log.debug("Disconnect " + statusCode + ": " + reason);
}
//Notify connection opening and closing latches of the closed connection
openLatch.countDown();
closeLatch.countDown();
connected = false;
}
示例6: handleClose
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketClose; //导入依赖的package包/类
@OnWebSocketClose
public void handleClose(int statusCode, String reason) throws IOException {
String uri = session.getUpgradeRequest().getRequestURI().getPath();
LOG.debug("websocket close: " + uri);
//set close info
session.getUpgradeResponse().setStatusCode(statusCode);
session.getUpgradeResponse().setStatusReason(reason);
//find hanlder
WebSocketHandler handler = getHandler(uri);
if (handler == null) {
session.getUpgradeResponse().setStatusCode(404);
return;
}
//get file
String file = handler.getClose();
if (StringUtils.isEmpty(file)) {
session.disconnect();
return;
}
bindAndRun(handler, file, null, null);
session.disconnect();
}
示例7: close
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketClose; //导入依赖的package包/类
@OnWebSocketClose
public void close(Session session, int statusCode, String reason) {
WebSocketSession webSocketSession = (WebSocketSession)session;
if (webSocketSession == null) {
LOG.info("SocketIOSession was not WebSocketSession");
return;
}
Map<String, String> query = query(webSocketSession.getRequestURI().getQuery());
String sid = query.get("sid").getOrElse("");
LOG.info("Removing user with session id '{}'", sid);
sessions.remove(sid);
sessions.of("/admin").forEach(s -> {
Try.run(() -> {
s.getWebsocketSession().getRemote().sendString(clientCountMessage());
});
});
//if (path == "/admin") {
//admins = admins.remove(session);
//} else {
//clients.remove(session);
//updateAdmins(admins, clients);
//}
}
示例8: onClose
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketClose; //导入依赖的package包/类
@OnWebSocketClose
public void onClose(int statusCode, String reason) {
if (statusCode != StatusCode.NORMAL)
log.error("Disconnect " + statusCode + ": " + reason);
else
log.debug("Disconnect " + statusCode + ": " + reason);
openLatch.countDown();
closeLatch.countDown();
connected = false;
}
示例9: onClose
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketClose; //导入依赖的package包/类
@OnWebSocketClose
public void onClose(int statusCode, String reason) {
log.warn("WebSocket closed " + statusCode + " " + reason);
if(CONNECT_FAILURE_REASONS.contains(reason)) {
log.warn("WebSocket closure indicates session has expired. Clearing credentials.");
apiAccess.invalidateAccess();
return;
}
connect();
}
示例10: onClose
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketClose; //导入依赖的package包/类
@OnWebSocketClose
public void onClose(int statusCode, String reason)
{
System.out.printf("Connection closed for fuck say: %d - %s%n",statusCode,reason);
this.session = null;
latch.countDown(); // trigger latch
}
示例11: onWebSocketClose
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketClose; //导入依赖的package包/类
@OnWebSocketClose
public void onWebSocketClose(Session session, int closeCode, String closeReason) {
log.debug("Closing websocket");
this.eventsSubscription.dispose();
session.close(closeCode, closeReason);
}
示例12: onClose
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketClose; //导入依赖的package包/类
/**
* Callback hook for Connection close events.
*/
@OnWebSocketClose
public void onClose(int statusCode, String reason) {
session = null;
futureSession = null;
if (log.isLoggable(Level.INFO))
log.log(Level.INFO,"Disconnected from "+((addr==null)?"<null>":addr.toString())+" statusCode:"+statusCode+", reason:"+reason);
pool.removeSession(this);
pool.getRemovalCallback().onCloseConnection(this);
}
示例13: onWebSocketClose
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketClose; //导入依赖的package包/类
@OnWebSocketClose
public void onWebSocketClose(int statusCode, String reason) {
CloseStatus closeStatus = new CloseStatus(statusCode, reason);
try {
this.webSocketHandler.afterConnectionClosed(this.wsSession, closeStatus);
}
catch (Throwable ex) {
if (logger.isErrorEnabled()) {
logger.error("Unhandled error for " + this.wsSession, ex);
}
}
}
示例14: OnClose
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketClose; //导入依赖的package包/类
@OnWebSocketClose
public void OnClose(Session session, int statusCode, String reason)
{
LOG.info("OnClose({}, {})", statusCode, reason);
_protocolEngine.OnClose(this);
_closeLatch.countDown();
}
开发者ID:djalmasantos,项目名称:blinktrade_api_java_client_sample,代码行数:8,代码来源:WebSocketClientConnection.java
示例15: onClose
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketClose; //导入依赖的package包/类
@OnWebSocketClose
public void onClose(int statusCode, String reason) throws IOException, ExecutionException, InterruptedException {
// 1000 = Normal close, 1001 = Going away
if (statusCode != 1000 && statusCode != 1001) {
System.err.println("Websocket closed, code: " + statusCode + ", reason: " + reason);
}
// Add dummy end message from server
messages.add(Json.object(ACTION, ACTION_END));
}