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

io.neow3j.protocol.Neow3jService Maven / Gradle / Ivy

There is a newer version: 3.23.0
Show newest version
package io.neow3j.protocol;

import io.neow3j.protocol.core.Request;
import io.neow3j.protocol.core.Response;
import io.neow3j.protocol.notifications.Notification;
import io.reactivex.Observable;

import java.io.IOException;
import java.util.concurrent.CompletableFuture;

/**
 * Services API.
 */
public interface Neow3jService {

    /**
     * Performs a synchronous JSON-RPC request.
     *
     * @param request      the request to perform.
     * @param responseType the class of a data item returned by the request.
     * @param           the type of a data item returned by the request.
     * @return the deserialized JSON-RPC response.
     * @throws IOException if the request could not be performed.
     */
     T send(Request request, Class responseType) throws IOException;

    /**
     * Performs an asynchronous JSON-RPC request.
     *
     * @param request      the request to perform.
     * @param responseType the class of a data item returned by the request.
     * @param           the type of a data item returned by the request.
     * @return a CompletableFuture that will be completed when a result is returned or the request has failed.
     */
     CompletableFuture sendAsync(Request request, Class responseType);

    /**
     * Subscribe to a stream of notifications. A stream of notifications is opened by by performing a specified
     * JSON-RPC request and is closed by calling the unsubscribe method. Different WebSocket implementations use
     * different pair of subscribe/unsubscribe methods.
     * 

* This method creates an Observable that can be used to subscribe to new notifications. When a client * unsubscribes from this Observable the service unsubscribes from the underlying stream of events. * * @param request the JSON-RPC request that will be send to subscribe to a stream of events. * @param unsubscribeMethod the method that will be called to unsubscribe from a stream of notifications. * @param responseType the class of incoming events objects in a stream. * @param the type of incoming event objects. * @return an Observable that emits incoming events. */ > Observable subscribe( Request request, String unsubscribeMethod, Class responseType); /** * Closes resources used by the service. * * @throws IOException if a service failed to close all resources. */ void close() throws IOException; }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy