I'm having a hard time figuring out how to write a Java Lambda function that handles Websocket messages where the Websockets are handled by the new API Gateway function that was just released towards the end of 2018. Specific questions: * What type should I use for the input object? I'm currently using APIGatewayProxyRequestEvent. Is there a type specific to Websocket requests? I don't see one in aws-lambda-java-events-2.2.5.jar. * If I am using the correct type, how can I access the connection ID? Do I somehow need to use API Mapping? I saw this link but it doesn't actually tell you how to do the mapping for Websockets, which seem to have different options than REST APIs for this sort of thing. https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api-mapping-template-reference.html
Thanks in advance!
public class WebsocketHandler implements RequestHandler {
@Override
public APIGatewayProxyResponseEvent handleRequest(APIGatewayProxyRequestEvent input, Context context) {
context.getLogger().log("Input: " + input);
context.getLogger().log("Context: " + context);
ProxyRequestContext requestContext = input.getRequestContext();
context.getLogger().log("requestContext: " + requestContext);
// I don't see Connection ID in any of these
APIGatewayProxyResponseEvent response = new APIGatewayProxyResponseEvent();
response.setStatusCode(200);
response.setBody("All good here.");
return response;
}
}