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