Search in sources :

Example 1 with RequestProcessor

use of org.wso2.carbon.apimgt.gateway.inbound.websocket.request.RequestProcessor in project carbon-apimgt by wso2.

the class InboundWebSocketProcessor method handleRequest.

/**
 * This method process websocket request messages (publish messages) and
 * hand over the processing to relevant request intercepting processor for authentication, scope validation,
 * throttling etc.
 *
 * @param msg                   Websocket request message frame
 * @param inboundMessageContext InboundMessageContext
 * @return InboundProcessorResponseDTO with handshake processing response
 */
public InboundProcessorResponseDTO handleRequest(WebSocketFrame msg, InboundMessageContext inboundMessageContext) {
    RequestProcessor requestProcessor;
    String msgText = null;
    if (APIConstants.GRAPHQL_API.equals(inboundMessageContext.getElectedAPI().getApiType()) && msg instanceof TextWebSocketFrame) {
        requestProcessor = new GraphQLRequestProcessor();
        msgText = ((TextWebSocketFrame) msg).text();
    } else {
        requestProcessor = new RequestProcessor();
    }
    return requestProcessor.handleRequest(msg.content().capacity(), msgText, inboundMessageContext);
}
Also used : GraphQLRequestProcessor(org.wso2.carbon.apimgt.gateway.inbound.websocket.request.GraphQLRequestProcessor) TextWebSocketFrame(io.netty.handler.codec.http.websocketx.TextWebSocketFrame) RequestProcessor(org.wso2.carbon.apimgt.gateway.inbound.websocket.request.RequestProcessor) GraphQLRequestProcessor(org.wso2.carbon.apimgt.gateway.inbound.websocket.request.GraphQLRequestProcessor)

Aggregations

TextWebSocketFrame (io.netty.handler.codec.http.websocketx.TextWebSocketFrame)1 GraphQLRequestProcessor (org.wso2.carbon.apimgt.gateway.inbound.websocket.request.GraphQLRequestProcessor)1 RequestProcessor (org.wso2.carbon.apimgt.gateway.inbound.websocket.request.RequestProcessor)1