javax.websocket.Session#getId ( )源码实例Demo

下面列出了javax.websocket.Session#getId ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@Override
public void initializeNativeSession(Session session) {
	super.initializeNativeSession(session);

	this.id = session.getId();
	this.uri = session.getRequestURI();

	this.acceptedProtocol = session.getNegotiatedSubprotocol();

	List<Extension> source = getNativeSession().getNegotiatedExtensions();
	this.extensions = new ArrayList<WebSocketExtension>(source.size());
	for (Extension ext : source) {
		this.extensions.add(new StandardToWebSocketExtensionAdapter(ext));
	}

	if (this.user == null) {
		this.user = session.getUserPrincipal();
	}
}
 
源代码2 项目: snoop   文件: SnoopRegistrationClient.java
/**
 * Sends message to the WebSocket server.
 *
 * @param endpoint The server endpoint
 * @param msg The message
 * @return a return message
 */
private String sendMessage(String endpoint, String msg) {

    LOGGER.config(() -> "Sending message: " + msg);

    String returnValue = "-1";
    try {
        WebSocketContainer container = ContainerProvider.getWebSocketContainer();
        String uri = serviceUrl + endpoint;
        Session session = container.connectToServer(this, URI.create(uri));
        session.getBasicRemote().sendText(msg != null ? msg : "");
        returnValue = session.getId();

    } catch (DeploymentException | IOException ex) {
        LOGGER.warning(ex.getMessage());
    }

    return returnValue;
}
 
public StandardWebSocketSession(Session session, HandshakeInfo info, DataBufferFactory factory,
		@Nullable MonoProcessor<Void> completionMono) {

	super(session, session.getId(), info, factory, completionMono);
}
 
public StandardWebSocketSession(Session session, HandshakeInfo info, DataBufferFactory factory,
		@Nullable MonoProcessor<Void> completionMono) {

	super(session, session.getId(), info, factory, completionMono);
}
 
源代码5 项目: quarks   文件: WebSocketClientConnector.java
private void updateId(Session session) {
    sid = session.getId();
    id = null;
}
 
源代码6 项目: scipio-erp   文件: ExampleWebSockets.java
/**
 * SCIPIO: getLogIdStr.
 * <p>
 * WARN: TODO: REVIEW: Unclear if truly good idea security-wise to print these IDs in log, 
 * but for this example currently do not see a risk. For real applications, you may
 * want to honor the <code>requestHandler.properties#show-sessionId-in-log</code> setting.
 */
private static String getLogIdStr(Session session) {
    return "'" + session.getId() + "'";
}