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 subclassingServerActor
and overriding its methods.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description V
handleCall(ActorRef<?> from, java.lang.Object id, CallMessage m)
Called to handle a synchronous request (one waiting for a response).void
handleCast(ActorRef<?> from, java.lang.Object id, CastMessage m)
Called to handle an asynchronous request (one that does not for a response).void
handleInfo(java.lang.Object m)
void
handleTimeout()
Called whenever the timeout set withsetTimeout
or supplied at construction expires without any message received.-
Methods inherited from interface co.paralleluniverse.actors.behaviors.Initializer
init, terminate
-
-
-
-
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 viaServer.call
(which is how it's usually done), this value will be returned by thecall
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 viaServer.call
, the exception will be thrown by thecall
method, possibly wrapped in aRuntimeException
. - If this method returns
null
, then a reply is not immediately sent, and thecall
method will remain blocked until a reply is sent manually withreply
orreplyError
.
- Parameters:
from
- the sender of the requestid
- the request's unique idm
- 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
- If this method returns a non-null value, it will be sent back to the sender of the request wrapped by an
-
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 requestid
- the request's unique idm
- the request- Throws:
SuspendExecution
-
handleInfo
void handleInfo(java.lang.Object m) throws SuspendExecution
- Parameters:
m
- the message- Throws:
SuspendExecution
-
handleTimeout
void handleTimeout() throws SuspendExecution
Called whenever the timeout set withsetTimeout
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
-
-