当前位置: 首页>>代码示例>>Java>>正文


Java WebSocketSession.getId方法代码示例

本文整理汇总了Java中org.springframework.web.socket.WebSocketSession.getId方法的典型用法代码示例。如果您正苦于以下问题:Java WebSocketSession.getId方法的具体用法?Java WebSocketSession.getId怎么用?Java WebSocketSession.getId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.web.socket.WebSocketSession的用法示例。


在下文中一共展示了WebSocketSession.getId方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: apply

import org.springframework.web.socket.WebSocketSession; //导入方法依赖的package包/类
@Override
public void apply(ApiRequest request, ApiResponse response, WebSocketSession session) {
    String msg = StringEscapeUtils.escapeHtml4(request.getMsg());
    if (StringUtils.isBlank(msg)) {
        return;
    }
    Map<String, Object> attributes = session.getAttributes();
    String id = session.getId();
    DrawPlayerInfo info = ((DrawPlayerInfo) attributes.get("info"));
    DrawGuessContext ctx = (DrawGuessContext) attributes.get("ctx");
    DrawGameStatus status = ctx.status();
    ArrayList<String> msgs = new ArrayList<>(2);
    if (status == DrawGameStatus.RUN) {
        if (StringUtils.equals(id, ctx.getCurrentUser())) {
            protectSecret(info, ctx, msg, msgs);
        } else {
            processGussPerson(info, ctx, msg, msgs);
        }
    } else {
        msgs.add("<b>" + info.getName() + "</b>: " + msg);
    }
    response.setCode(DrawCode.DRAW_MSG.getCode()).setData(msgs);
}
 
开发者ID:csdbianhua,项目名称:telemarket-skittle-alley,代码行数:24,代码来源:UserMsgHandler.java

示例2: stop

import org.springframework.web.socket.WebSocketSession; //导入方法依赖的package包/类
private synchronized void stop(WebSocketSession session) throws IOException {
  String sessionId = session.getId();
  if (teacherUserSession != null && teacherUserSession.getSession().getId().equals(sessionId)) {
    for (UserSession student : students.values()) {
      JsonObject response = new JsonObject();
      response.addProperty("id", "stopCommunication");
      student.sendMessage(response);
    }

    log.info("Releasing media pipeline");
    if (pipeline != null) {
      pipeline.release();
    }
    pipeline = null;
    teacherUserSession = null;
  } else if (students.containsKey(sessionId)) {
    if (students.get(sessionId).getWebRtcEndpoint() != null) {
      students.get(sessionId).getWebRtcEndpoint().release();
    }
    students.remove(sessionId);
  }
}
 
开发者ID:jake-kent,项目名称:TLIVideoConferencingv2,代码行数:23,代码来源:CallHandler.java

示例3: afterConnectionEstablished

import org.springframework.web.socket.WebSocketSession; //导入方法依赖的package包/类
@Override
public void afterConnectionEstablished(WebSocketSession session) throws Exception {
    String id = session.getId();
    clients.put(id, session);
    DrawGuessContext ctx = drawGuess.connected(session);
    JSONObject obj = new JSONObject();
    obj.put("info", session.getAttributes().get("info"));
    broadcast(transformToMsg(ApiResponse.code(DrawCode.USER_JOIN.getCode(), obj)), id);
    obj.put("players", clients.values()
            .stream()
            .map((w) -> w.getAttributes().get("info"))
            .collect(Collectors.toList()));
    obj.put("ctx", ctx);
    obj.put("assign", true);
    obj.put("timestamp", Instant.now().toEpochMilli());
    sendTo(transformToMsg(ApiResponse.code(DrawCode.USER_JOIN.getCode(), obj)), id);
}
 
开发者ID:csdbianhua,项目名称:telemarket-skittle-alley,代码行数:18,代码来源:DrawGuessWebSocket.java

示例4: afterConnectionClosed

import org.springframework.web.socket.WebSocketSession; //导入方法依赖的package包/类
@Override
public void afterConnectionClosed(WebSocketSession session, CloseStatus status) throws Exception {
    String id = session.getId();
    clients.remove(id);
    drawGuess.closed(session);
    broadcast(transformToMsg(ApiResponse.code(DrawCode.USER_LEFT.getCode(), session.getAttributes().get("info"))),
            null);
}
 
开发者ID:csdbianhua,项目名称:telemarket-skittle-alley,代码行数:9,代码来源:DrawGuessWebSocket.java


注:本文中的org.springframework.web.socket.WebSocketSession.getId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。