当前位置: 首页>>代码示例>>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;未经允许,请勿转载。