Java Code Examples for javax.websocket.Session#getId()

The following examples show how to use javax.websocket.Session#getId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StandardWebSocketSession.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@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();
	}
}
 
Example 2
Source File: SnoopRegistrationClient.java    From snoop with MIT License 6 votes vote down vote up
/**
 * 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;
}
 
Example 3
Source File: StandardWebSocketSession.java    From spring-analysis-note with MIT License 4 votes vote down vote up
public StandardWebSocketSession(Session session, HandshakeInfo info, DataBufferFactory factory,
		@Nullable MonoProcessor<Void> completionMono) {

	super(session, session.getId(), info, factory, completionMono);
}
 
Example 4
Source File: StandardWebSocketSession.java    From java-technology-stack with MIT License 4 votes vote down vote up
public StandardWebSocketSession(Session session, HandshakeInfo info, DataBufferFactory factory,
		@Nullable MonoProcessor<Void> completionMono) {

	super(session, session.getId(), info, factory, completionMono);
}
 
Example 5
Source File: WebSocketClientConnector.java    From quarks with Apache License 2.0 4 votes vote down vote up
private void updateId(Session session) {
    sid = session.getId();
    id = null;
}
 
Example 6
Source File: ExampleWebSockets.java    From scipio-erp with Apache License 2.0 2 votes vote down vote up
/**
 * 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() + "'";
}