All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.infomaximum.platform.component.frontend.request.GRequestWebSocket Maven / Gradle / Ivy

There is a newer version: 0.1.15p24
Show newest version
package com.infomaximum.platform.component.frontend.request;

import com.infomaximum.cluster.graphql.struct.GRequest;
import com.infomaximum.network.struct.HandshakeData;
import jakarta.servlet.http.Cookie;

import java.io.Serializable;
import java.time.Instant;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

public class GRequestWebSocket extends GRequest {

    private final String sessionUuid;

    private final Map parameters;
    private final Cookie[] cookies;

    private final HandshakeData handshakeData;

    public GRequestWebSocket(Instant instant, RemoteAddress remoteAddress, String query, HashMap queryVariables, String operationName, String xTraceId, String sessionUuid, Map parameters, Cookie[] cookies) {
        this(instant, remoteAddress, query, queryVariables, operationName, xTraceId, sessionUuid, parameters, cookies, null);
    }

    public GRequestWebSocket(Instant instant, RemoteAddress remoteAddress, String query, HashMap queryVariables, String operationName, String xTraceId, String sessionUuid, Map parameters, Cookie[] cookies, HandshakeData handshakeData) {
        super(instant, remoteAddress, query, queryVariables, operationName, xTraceId);

        this.sessionUuid = sessionUuid;
        this.parameters = parameters != null ? parameters : new HashMap<>();
        this.cookies = cookies;

        this.handshakeData = handshakeData;
    }

    public String getSessionUuid() {
        return sessionUuid;
    }

    public Map getParameters() {
        return Collections.unmodifiableMap(parameters);
    }

    public String getParameter(String name) {
        return parameters.get(name);
    }

    public Cookie getCookie(String name) {
        if (cookies != null) {
            for (Cookie cookie : cookies) {
                if (name.equals(cookie.getName())) return cookie;
            }
        }
        return null;
    }

    public  T getHandshakeData() {
        return (T) handshakeData;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy