Example usage for org.springframework.web.socket WebSocketSession getRemoteAddress

List of usage examples for org.springframework.web.socket WebSocketSession getRemoteAddress

Introduction

In this page you can find the example usage for org.springframework.web.socket WebSocketSession getRemoteAddress.

Prototype

@Nullable
InetSocketAddress getRemoteAddress();

Source Link

Document

Return the address of the remote client.

Usage

From source file:com.hxh.websocket.handler.AndroidEndPoint.java

private String getClientAddress(WebSocketSession session) {
    String s = session.getRemoteAddress().getHostName();
    int cp = session.getRemoteAddress().getPort();
    return s + ":" + cp;
}

From source file:io.sevenluck.chat.websocket.EchoWebSocketHandler.java

@Override
public void afterConnectionEstablished(WebSocketSession session) throws Exception {
    logger.info("afterConnectionEstablished" + session.getRemoteAddress().getAddress() + ", attr "
            + session.getAttributes().toString());
    List<ChatRoom> rooms = repository.findByName("bla");

    this.sessions.add(session);
}

From source file:io.sevenluck.chat.websocket.EchoWebSocketHandler.java

@Override
public void afterConnectionClosed(WebSocketSession session, CloseStatus status) throws Exception {
    logger.info("afterConnectionClosed" + session.getRemoteAddress().getAddress());

    sessions.remove(session);/*from w w  w  .  j  av a 2  s.c  o  m*/
}

From source file:com.zb.app.websocket.server.wrapper.ClientWrapper.java

public ClientWrapper(WebSocketSession socketSession) {
    this.address = socketSession.getRemoteAddress().getAddress();
    this.ip = address.getHostAddress();

    this.cookieManager = new WebSocketCookieManager(socketSession.getHandshakeHeaders());
    // ?1?/*from w  w w  .  ja v  a 2 s  .c  o  m*/
    long lastLoginTime = NumberParser.parseLong(cookieManager.get(CookieKeyEnum.last_login_time), 0);
    if (lastLoginTime <= 0 || System.currentTimeMillis() - lastLoginTime > MAX_LAST_ACCESS_TIME) {
        ZuobianWebUserBuilder.loginOut(cookieManager);
    } else {
        this.webUser = ZuobianWebUserBuilder.create(cookieManager);
        this.mId = webUser.getmId();
    }
}

From source file:ymanv.forex.websocket.RatesWebSocketHandler.java

@Override
public void afterConnectionEstablished(WebSocketSession session) {
    LOG.debug("Opened new {} in instance {}", session.getClass().getSimpleName(), session.getRemoteAddress());
    sessions.add(session);/*from  w  w w  . j a  va 2 s  . c o m*/
}

From source file:ymanv.forex.websocket.RatesWebSocketHandler.java

@Override
public void afterConnectionClosed(WebSocketSession session, CloseStatus status) {
    LOG.debug("Closed {} in instance {}", session.getClass().getSimpleName(), session.getRemoteAddress());
    sessions.remove(session);/*from   w w  w  . jav a 2 s .c  o m*/
}

From source file:com.hxh.websocket.handler.AndroidEndPoint.java

private void doUserLogin(WebSocketSession session, String[] upp) {
    //String clientAddress = getClientAddress(session);
    if (upp != null && upp.length == 5) {
        String clientIp = session.getRemoteAddress().getHostName();
        service.registerUser(upp[0], upp[1], clientIp, upp[2], upp[3], upp[4], session);
    }//from   w w w  .  j  a v  a2  s.  c om
}

From source file:io.sevenluck.chat.websocket.ChatWebSocketHandler.java

@Override
public void afterConnectionEstablished(WebSocketSession session) throws Exception {
    logger.info("afterConnectionEstablished from ip " + session.getRemoteAddress().getAddress());

    final String token = (String) session.getAttributes().get(HttpAuthTokenHandShakeInterceptor.X_TOKEN);
    List<ChatSession> chatSessions = chatSessionRepository.findByAuthtoken(token);
    if (!sessions.isEmpty()) {
        logger.info("chatsession {} assigned to token {}", chatSessions.get(0), token);
        this.sessionMap.put(token, new SessionItem(chatSessions.get(0), session));
    }/*  www. j  ava2  s . c o m*/
}

From source file:org.kurento.jsonrpc.internal.ws.JsonRpcWebSocketHandler.java

@Override
public void afterConnectionEstablished(WebSocketSession session) throws Exception {

    // We send this notification to the JsonRpcHandler when the JsonRpc
    // session is established, not when websocket session is established
    log.info("{} Client connection stablished from {}", label, session.getRemoteAddress());
}

From source file:ca.uhn.fhir.jpa.subscription.SubscriptionWebsocketHandler.java

@Override
public void afterConnectionEstablished(WebSocketSession theSession) throws Exception {
    super.afterConnectionEstablished(theSession);
    ourLog.info("Incoming WebSocket connection from {}", theSession.getRemoteAddress());
}