Interface ServerHandler<CallMessage,​V,​CastMessage>

  • All Superinterfaces:
    Initializer
    All Known Implementing Classes:
    AbstractServerHandler

    public interface ServerHandler<CallMessage,​V,​CastMessage>
    extends Initializer
    A delegate object that can be used instead of subclassing ServerActor and overriding its methods.
    • Method Detail

      • handleCall

        V handleCall​(ActorRef<?> from,
                     java.lang.Object id,
                     CallMessage m)
              throws java.lang.Exception,
                     SuspendExecution
        Called to handle a synchronous request (one waiting for a response).
        • If this method returns a non-null value, it will be sent back to the sender of the request wrapped by an ErrorResponseMessage; if the request was sent via Server.call (which is how it's usually done), this value will be returned by the call method.
        • If this method throws an exception, it will be sent back to the sender of the request wrapped by an ErrorResponseMessage; if the request was sent via Server.call, the exception will be thrown by the call method, possibly wrapped in a RuntimeException.
        • If this method returns null, then a reply is not immediately sent, and the call method will remain blocked until a reply is sent manually with reply or replyError.
        Parameters:
        from - the sender of the request
        id - the request's unique id
        m - the request
        Returns:
        a value that will be sent as a response to the sender of the request.
        Throws:
        java.lang.Exception - if thrown, it will be sent back to the sender of the request.
        SuspendExecution
      • handleCast

        void handleCast​(ActorRef<?> from,
                        java.lang.Object id,
                        CastMessage m)
                 throws SuspendExecution
        Called to handle an asynchronous request (one that does not for a response).
        Parameters:
        from - the sender of the request
        id - the request's unique id
        m - the request
        Throws:
        SuspendExecution
      • handleInfo

        void handleInfo​(java.lang.Object m)
                 throws SuspendExecution
        Called to handle any message sent to this actor that is neither a call nor a cast.
        Parameters:
        m - the message
        Throws:
        SuspendExecution
      • handleTimeout

        void handleTimeout()
                    throws SuspendExecution
        Called whenever the timeout set with setTimeout or supplied at construction expires without any message received. The countdown is reset after every received message. This method will be triggered multiple times if a message is not received for a period of time longer than multiple timeout durations.
        Throws:
        SuspendExecution