Search in sources :

Example 1 with RpcResponse

use of com.jim.framework.rpc.common.RpcResponse in project jim-framework by jiangmin168168.

the class AbstractHeartbeatHandler method sendPong.

protected void sendPong(ChannelHandlerContext channelHandlerContext) {
    RpcMessage message = new RpcMessage();
    String body = new Date().toString();
    RpcResponse rpcResponse = new RpcResponse();
    rpcResponse.setResult(body);
    RpcMessageHeader messageHeader = new RpcMessageHeader();
    messageHeader.setLength(body.length());
    messageHeader.setType(Constants.MESSAGE_TYPE_HEARTBEAT_PONG);
    message.setMessageHeader(messageHeader);
    message.setMessageBody(rpcResponse);
    channelHandlerContext.writeAndFlush(message);
}
Also used : RpcMessageHeader(com.jim.framework.rpc.protocol.RpcMessageHeader) RpcMessage(com.jim.framework.rpc.protocol.RpcMessage) RpcResponse(com.jim.framework.rpc.common.RpcResponse) Date(java.util.Date)

Example 2 with RpcResponse

use of com.jim.framework.rpc.common.RpcResponse in project jim-framework by jiangmin168168.

the class ResponseFuture method cancel.

@Override
public boolean cancel(boolean mayInterruptIfRunning) {
    if (!mayInterruptIfRunning) {
        return false;
    }
    RpcResponse errorResult = new RpcResponse();
    errorResult.setRequestId(this.request.getRequestId());
    errorResult.setResult("request future has been canceled.");
    response = errorResult;
    this.isCancelledFlag = true;
    return true;
}
Also used : RpcResponse(com.jim.framework.rpc.common.RpcResponse)

Aggregations

RpcResponse (com.jim.framework.rpc.common.RpcResponse)2 RpcMessage (com.jim.framework.rpc.protocol.RpcMessage)1 RpcMessageHeader (com.jim.framework.rpc.protocol.RpcMessageHeader)1 Date (java.util.Date)1