當前位置: 首頁>>代碼示例>>Java>>正文


Java OnWebSocketClose類代碼示例

本文整理匯總了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);
    }
}
 
開發者ID:ppieczul,項目名稱:org.openhab.binding.loxone,代碼行數:23,代碼來源:LxWsClient.java

示例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;
}
 
開發者ID:Fyro-Ing,項目名稱:JMeter-WebSocket-StompSampler,代碼行數:18,代碼來源:ServiceSocket.java

示例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();
    }
}
 
開發者ID:BitcoinFullnode,項目名稱:ROKOS-OK-Bitcoin-Fullnode,代碼行數:27,代碼來源:PeerWebSocket.java

示例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;
	}
}
 
開發者ID:paluka,項目名稱:Multi-Leap,代碼行數:23,代碼來源:ClientSocket.java

示例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;
}
 
開發者ID:maciejzaleski,項目名稱:JMeter-WebSocketSampler,代碼行數:17,代碼來源:ServiceSocket.java

示例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();
  }
 
開發者ID:lane-cn,項目名稱:getty,代碼行數:27,代碼來源:WebSocketInstance.java

示例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);
    //}
}
 
開發者ID:javaBin,項目名稱:Switcharoo,代碼行數:26,代碼來源:Ws.java

示例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;
}
 
開發者ID:Blazemeter,項目名稱:jmeter-bzm-plugins,代碼行數:11,代碼來源:WebSocketConnection.java

示例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();
}
 
開發者ID:BuaBook,項目名稱:buabook-api-interface,代碼行數:14,代碼來源:BuaBookApiWebSocket.java

示例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
}
 
開發者ID:BadPlayer555,項目名稱:MeMezBots-Dev,代碼行數:8,代碼來源:ToUpperClientSocket.java

示例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);
}
 
開發者ID:adamkewley,項目名稱:jobson,代碼行數:7,代碼來源:ObservableSocket.java

示例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);
  }
 
開發者ID:gustavohbf,項目名稱:robotoy,代碼行數:13,代碼來源:WebSocketHandlerImpl.java

示例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);
		}
	}
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:13,代碼來源:JettyWebSocketHandlerAdapter.java

示例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));
}
 
開發者ID:graknlabs,項目名稱:grakn,代碼行數:11,代碼來源:JsonSession.java


注:本文中的org.eclipse.jetty.websocket.api.annotations.OnWebSocketClose類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。