public interface FunctionResolver
Function
.
or when aClient client = ClientFactory.getDefault().newClient(); RequestBuilder request = client.newRequestBuilder() .method(Request.METHOD.GET) .uri(targetUrl + "/suspend") .decoder(new Decoder<String, POJO>() { @Override public POJO decode(String s) { return new POJO(s); } }) .transport(Request.TRANSPORT.WEBSOCKET); Socket socket = client.create(); socket.on(Event.MESSAGE, new Function<POJO>() { @Override public void on(POJO t) { response.set(t); } })
Decoder
share the same type as the
defined Function. For example:
An application can define its own Decoder to Function Mapper be writing the appropriate FunctionResolver. By default, theClient client = ClientFactory.getDefault().newClient(); RequestBuilder request = client.newRequestBuilder() .method(Request.METHOD.GET) .uri(targetUrl + "/suspend") .decoder(new Decoder<String, POJO>() { @Override public POJO decode(String s) { return new POJO(s); } }) .transport(Request.TRANSPORT.WEBSOCKET); Socket socket = client.create(); socket.on(new Function<POJO>() { @Override public void on(POJO t) { response.set(t); } })
DEFAULT
is used.Modifier and Type | Field and Description |
---|---|
static FunctionResolver |
DEFAULT |
Modifier and Type | Method and Description |
---|---|
boolean |
resolve(String message,
Object functionName,
FunctionWrapper fn)
Resolve the current message
|
static final FunctionResolver DEFAULT
boolean resolve(String message, Object functionName, FunctionWrapper fn)
message
- the original response's body receivedfunctionName
- the default function name taken from Event
or from a custom FunctionResolverfn
- The current FunctionWrapper
Function
can be invoked.Copyright © 2015. All Rights Reserved.