Search in sources :

Example 1 with OperationModelContext

use of software.amazon.awssdk.eventstreamrpc.OperationModelContext in project aws-iot-device-sdk-java-v2 by aws.

the class TestIpcServiceHandler method getOperationHandler.

@Override
public Function<OperationContinuationHandlerContext, ? extends ServerConnectionContinuationHandler> getOperationHandler(final String operationName) {
    final EventStreamRPCServiceModel svcModel = this.serviceModel;
    System.out.println("Operation handler retrieved for operation name: " + operationName);
    return (context) -> {
        final TestOperationContinuationHandler handler = new TestOperationContinuationHandler(context) {

            @Override
            public OperationModelContext getOperationModelContext() {
                return svcModel.getOperationModelContext(operationName);
            }

            @Override
            protected void onStreamClosed() {
                streamClosed = true;
            }

            @Override
            public EventStreamJsonMessage handleRequest(EventStreamJsonMessage request) {
                System.out.println("Handling request...");
                return requestHandler.apply(request);
            }

            @Override
            public void handleStreamEvent(EventStreamJsonMessage streamRequestEvent) {
                System.out.println("Handling request stream event...");
            }
        };
        continuationHandlerQueue.offer(new AbstractMap.SimpleImmutableEntry<>(operationName, handler));
        return handler;
    };
}
Also used : OperationModelContext(software.amazon.awssdk.eventstreamrpc.OperationModelContext) EventStreamRPCServiceModel(software.amazon.awssdk.eventstreamrpc.EventStreamRPCServiceModel) EventStreamRPCServiceHandler(software.amazon.awssdk.eventstreamrpc.EventStreamRPCServiceHandler) OperationContinuationHandlerContext(software.amazon.awssdk.eventstreamrpc.OperationContinuationHandlerContext) Collection(java.util.Collection) Set(java.util.Set) EventStreamJsonMessage(software.amazon.awssdk.eventstreamrpc.model.EventStreamJsonMessage) Function(java.util.function.Function) HashSet(java.util.HashSet) AbstractMap(java.util.AbstractMap) ServerConnectionContinuationHandler(software.amazon.awssdk.crt.eventstream.ServerConnectionContinuationHandler) Map(java.util.Map) OperationContinuationHandler(software.amazon.awssdk.eventstreamrpc.OperationContinuationHandler) Optional(java.util.Optional) Queue(java.util.Queue) LinkedList(java.util.LinkedList) EventStreamRPCServiceModel(software.amazon.awssdk.eventstreamrpc.EventStreamRPCServiceModel) OperationModelContext(software.amazon.awssdk.eventstreamrpc.OperationModelContext) EventStreamJsonMessage(software.amazon.awssdk.eventstreamrpc.model.EventStreamJsonMessage)

Aggregations

AbstractMap (java.util.AbstractMap)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Queue (java.util.Queue)1 Set (java.util.Set)1 Function (java.util.function.Function)1 ServerConnectionContinuationHandler (software.amazon.awssdk.crt.eventstream.ServerConnectionContinuationHandler)1 EventStreamRPCServiceHandler (software.amazon.awssdk.eventstreamrpc.EventStreamRPCServiceHandler)1 EventStreamRPCServiceModel (software.amazon.awssdk.eventstreamrpc.EventStreamRPCServiceModel)1 OperationContinuationHandler (software.amazon.awssdk.eventstreamrpc.OperationContinuationHandler)1 OperationContinuationHandlerContext (software.amazon.awssdk.eventstreamrpc.OperationContinuationHandlerContext)1 OperationModelContext (software.amazon.awssdk.eventstreamrpc.OperationModelContext)1 EventStreamJsonMessage (software.amazon.awssdk.eventstreamrpc.model.EventStreamJsonMessage)1