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


Java OnWebSocketConnect類代碼示例

本文整理匯總了Java中org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect的典型用法代碼示例。如果您正苦於以下問題:Java OnWebSocketConnect類的具體用法?Java OnWebSocketConnect怎麽用?Java OnWebSocketConnect使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


OnWebSocketConnect類屬於org.eclipse.jetty.websocket.api.annotations包,在下文中一共展示了OnWebSocketConnect類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onConnect

import org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect; //導入依賴的package包/類
/**
 * Callback hook for Connection open events.
 *
 * @param session the user session which is opened.
 */
@OnWebSocketConnect
public void onConnect(Session session) {
	this.session = session;
	this.futureSession = null; // don't need this anymore
	this.addr = session.getRemoteAddress().getAddress();
	this.remotePort = session.getRemoteAddress().getPort();
	this.localAddr = session.getLocalAddress().getAddress();
	this.localPort = session.getLocalAddress().getPort();
	this.path = session.getUpgradeRequest().getRequestURI().getPath();
	if (session.getUpgradeRequest() instanceof ClientUpgradeRequest) {
		this.key = ((ClientUpgradeRequest)session.getUpgradeRequest()).getKey();
	}
	else {
		this.key = session.getUpgradeRequest().getHeader("Sec-WebSocket-Key");
	}
    if (log.isLoggable(Level.INFO)) 
    	log.log(Level.INFO,"Connected with "+((addr==null)?"<null>":addr.toString())+" through local address "+localAddr.getHostAddress());
    pool.addSession(this);
    pool.getInclusionCallback().onStartConnection(this);
}
 
開發者ID:gustavohbf,項目名稱:robotoy,代碼行數:26,代碼來源:WebSocketHandlerImpl.java

示例2: handleConnect

import org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect; //導入依賴的package包/類
@OnWebSocketConnect
  public void handleConnect(Session session) {
String uri = session.getUpgradeRequest().getRequestURI().getPath();
LOG.debug("websocket connect: " + uri);

//create session
this.session = session;
this.bindingSession = new cn.batchfile.getty.binding.socket.Session(session);

//find hanlder
WebSocketHandler handler = getHandler(uri);
if (handler == null) {
	session.getUpgradeResponse().setStatusCode(404);
	return;
}

//get file
String file = handler.getConnect();
if (StringUtils.isEmpty(file)) {
	return;
}

bindAndRun(handler, file, null, null);
  }
 
開發者ID:lane-cn,項目名稱:getty,代碼行數:25,代碼來源:WebSocketInstance.java

示例3: connect

import org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect; //導入依賴的package包/類
@OnWebSocketConnect
public void connect(Session session) {
    WebSocketSession webSocketSession = (WebSocketSession)session;
    if (webSocketSession == null) {
        LOG.info("Session was not WebSocketSession");
        return;
    }
    Map<String, String> query = query(webSocketSession.getRequestURI().getQuery());
    SocketIOSession s = query.get("sid")
        .flatMap(sessions::get)
        .getOrElse(() -> {
            LOG.warn("Could not find session for sid, ignoring");
            return null;
        });

    if (s != null) {
        s.setWebsocketSession(session);
    }
}
 
開發者ID:javaBin,項目名稱:Switcharoo,代碼行數:20,代碼來源:Ws.java

示例4: onConnect

import org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect; //導入依賴的package包/類
@OnWebSocketConnect
public void onConnect(Session session) throws Exception {
    this.session = session;
    socketHealthService.register(this);
    LOGGER.debug("{} connected", sessionName());

    session.getRemote().sendString(consoleLogCharsetJSONMessage);

    long start = parseStartLine(session.getUpgradeRequest());
    LOGGER.debug("{} sending logs for {} starting at line {}.", sessionName(), jobIdentifier, start);

    try {
        handler.process(this, jobIdentifier, start);
    } catch (IOException e) {
        if ("Connection output is closed".equals(e.getMessage())) {
            LOGGER.debug("{} client (likely, browser) closed connection prematurely.", sessionName());
            close(); // for good measure
        } else {
            throw e;
        }
    }
}
 
開發者ID:gocd,項目名稱:gocd,代碼行數:23,代碼來源:ConsoleLogSocket.java

示例5: onConnect

import org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect; //導入依賴的package包/類
@OnWebSocketConnect
public void onConnect(Session session) {
    logger.info("---- onConnect");
    try {
        String subStr = "{"
                + " \"command\"    : \"subscribe\","
                + " \"req.id\"     : \"" + UUID.randomUUID().toString() + "\","
                + " \"event\"      : \"*\","
                + " \"session_id\" : \"" + protocol.getSessionId() + "\""
                + "}";
        session.getRemote().sendString(subStr);
        String gid = protocol.getGroupId();
        if (gid != null) {
            subStr = "{"
                    + " \"command\"    : \"subscribe\","
                    + " \"req.id\"     : \"" + UUID.randomUUID().toString() + "\","
                    + " \"event\"      : \"*\","
                    + " \"group_id\" : \"" + "1" + "\""
                    + "}";
            session.getRemote().sendString(subStr);
        }
        connected = true;
    } catch (IOException ex) {
        java.util.logging.Logger.getLogger(PushReceiver.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
開發者ID:montsuqi,項目名稱:monsiaj,代碼行數:27,代碼來源:PushReceiver.java

示例6: onConnect

import org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect; //導入依賴的package包/類
@OnWebSocketConnect
public void onConnect(Session newWebSocket) {
	this.session = newWebSocket;
	
	log.info("Broker Client WebSocket open: " + session.getRemoteAddress());
	session.setIdleTimeout(CLIENT_WS_IDLE_TIMEOUT_MS);
	
	Broadcaster.getInstance().subscribe(this);
	onConnectQuerier.queryApiOnClientConnect();
}
 
開發者ID:BuaBook,項目名稱:buabook-api-interface,代碼行數:11,代碼來源:ClientWebSocket.java

示例7: onConnect

import org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect; //導入依賴的package包/類
@OnWebSocketConnect
public void onConnect(Session session) throws AuthenticationException
{
	Map<String, List<String>> params = session.getUpgradeRequest().getParameterMap();
	List<String> keys = params.get("key");
	if (keys == null || keys.size() != 1 || !keys.get(0).equals(NMOConfiguration.INSTANCE.integrations.webUI.ultiwakerAPI.apiSecurityKey))
	{
		throw new AuthenticationException("Not authorized");
	}
	this.session = session;
	this.connectionIP = session.getRemoteAddress().getAddress().toString();
	connections.add(this);
	log.info("UWAPI connect from " + this.connectionIP);
}
 
開發者ID:PolyphasicDevTeam,項目名稱:NoMoreOversleeps,代碼行數:15,代碼來源:UltiwakerWebSocketHandler.java

示例8: OnOpen

import org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect; //導入依賴的package包/類
@OnWebSocketConnect
public void OnOpen(Session sess)
{
	LOG.info("OnOpen({})",sess);
	this._session = sess;
	_protocolEngine.OnOpen(this);
	_scheduler.scheduleAtFixedRate(
	    new TestRequest(this), 
	    _testRequestDelayInSeconds, 
	    _testRequestDelayInSeconds, 
	    TimeUnit.SECONDS
	);
}
 
開發者ID:djalmasantos,項目名稱:blinktrade_api_java_client_sample,代碼行數:14,代碼來源:WebSocketClientConnection.java

示例9: onConnect

import org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect; //導入依賴的package包/類
@OnWebSocketConnect
public void onConnect(Session user) throws Exception 
{
    System.out.println("Connected " + user.getRemoteAddress().getHostString() );
    if (RobotDriver.master == null) RobotDriver.master = user;
    RobotDriver.userSet.add(user);

    if (RobotDriver.robot instanceof SideIRSensors){
        RobotDriver.broadcastRightIRSensorMessage(((SideIRSensors)RobotDriver.robot).getRightIRSensor().isTriggered());
        RobotDriver.broadcastLeftIRSensorMessage(((SideIRSensors)RobotDriver.robot).getLeftIRSensor().isTriggered());
    }

}
 
開發者ID:fustinoni-net,項目名稱:PiRobotPlatform,代碼行數:14,代碼來源:RobotWebSocketHandler.java

示例10: onConnect

import org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect; //導入依賴的package包/類
@OnWebSocketConnect
public void onConnect(Session session) throws InterruptedException {
    active = true;
    System.out.println("Trying to Connect to: " + session.getRemoteAddress().getAddress());
    try {
        session.getRemote().sendString("REG|videosws|samtec");
        session.getRemote().sendString("MSG|videosws|videosws|U");
    }catch (IOException e) {
        e.printStackTrace();
    }
}
 
開發者ID:kevuno,項目名稱:Offline-Streamer,代碼行數:12,代碼來源:MyWebSocketHandler.java

示例11: connected

import org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect; //導入依賴的package包/類
/**
 * Invoked whenever a new connection is established. Configures the session and
 * stashes it in the SESSIONS map.
 *
 * @param session Session associated with the new connection.
 */
@OnWebSocketConnect
public void connected(Session session) {
    session.getPolicy().setMaxTextMessageSize(Config.sharedConfig().getApi().getMaxMessageSize());
    session.getPolicy().setMaxBinaryMessageSize(Config.sharedConfig().getApi().getMaxMessageSize());
    sessions.add(session);
    LOGGER.debug("New session {} connected!", session.getRemoteAddress().toString());
}
 
開發者ID:vitrivr,項目名稱:cineast,代碼行數:14,代碼來源:WebsocketAPI.java

示例12: onConnect

import org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect; //導入依賴的package包/類
@OnWebSocketConnect
 public void onConnect(Session session) {
     System.out.println("Connect: " + session.getRemoteAddress().getAddress());
     try {
session.getRemote().sendString("Hello Client");	
     } catch (Exception e) {
         System.out.println("Exception "+ e);
     }
 }
 
開發者ID:zekaf,項目名稱:jetty-nodes,代碼行數:10,代碼來源:MySocket.java

示例13: onConnect

import org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect; //導入依賴的package包/類
@OnWebSocketConnect
public void onConnect(Session session) {
    LOG.trace("onConnect {}", session);
    this.session = session;
    this.connectionKey = UUID.randomUUID().toString();
    sync.addSocket(this);
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:8,代碼來源:DefaultWebsocket.java

示例14: onConnect

import org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect; //導入依賴的package包/類
@OnWebSocketConnect
public void onConnect(Session session) throws IOException {

	LOG.debug("Ryzom WebSocket is now connected");
	LOG.trace("Session is {}", session);

	this.session = session;
	this.timestamp = System.currentTimeMillis();
}
 
開發者ID:sarxos,項目名稱:ryzom-network-client,代碼行數:10,代碼來源:Lv20Socket.java

示例15: onConnect

import org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect; //導入依賴的package包/類
@OnWebSocketConnect
public void onConnect(Session session) {
    System.out.printf("Got connect: %s%n", session);
    this.session = session;
    try {
        Future<Void> fut;
        fut = session.getRemote().sendStringByFuture("Hello");
        fut.get(2, TimeUnit.SECONDS);
        fut = session.getRemote().sendStringByFuture("Thanks for the conversation.");
        fut.get(2, TimeUnit.SECONDS);
        session.close(StatusCode.NORMAL, "I'm done");
    } catch (Throwable t) {
        t.printStackTrace();
    }
}
 
開發者ID:East196,項目名稱:maker,代碼行數:16,代碼來源:SimpleEchoSocket.java


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