Java Code Examples for org.fisco.bcos.channel.dto.ChannelResponse#setContent()
The following examples show how to use
org.fisco.bcos.channel.dto.ChannelResponse#setContent() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DBHandler.java From amdb-proxy with Apache License 2.0 | 6 votes |
@Override public void onPush(ChannelPush push) { Integer resultCode = 0; String resultData = ""; try { resultData = dbService.process(push.getContent()); } catch (Exception e) { resultCode = -1; logger.error("Process request error", e); } //construct back to the package ChannelResponse response = new ChannelResponse(); response.setMessageID(push.getMessageID()); response.setErrorCode(resultCode); response.setErrorMessage(""); response.setContent(resultData); logger.debug("Send response: {}", response.getContent()); push.sendResponse(response); }
Example 2
Source File: ChannelResponseCallback2.java From web3sdk with Apache License 2.0 | 6 votes |
public final void onTimeout() { logger.error("send message timeout:{}", message.getSeq()); ChannelResponse response = new ChannelResponse(); response.setErrorCode(ChannelMessageError.MESSAGE_TIMEOUT.getError()); response.setMessageID(message.getSeq()); response.setErrorMessage("send message timeout"); response.setContent(""); try { onResponseMessage(response); } catch (Exception e) { logger.error("timeout processing error:", e); } service.getSeq2Callback().remove(message.getSeq()); timeout.cancel(); }
Example 3
Source File: AMOPSubscription.java From WeEvent with Apache License 2.0 | 5 votes |
private static ChannelResponse toChannelResponse(ErrorCode errorCode, byte[] content) { ChannelResponse reply = new ChannelResponse(); reply.setErrorCode(errorCode.getCode()); reply.setErrorMessage(errorCode.getCodeDesc()); reply.setContent(content); return reply; }
Example 4
Source File: AMOPChannel.java From WeEvent with Apache License 2.0 | 5 votes |
private static ChannelResponse toChannelResponse(ErrorCode errorCode, byte[] content) { ChannelResponse reply = new ChannelResponse(); reply.setErrorCode(errorCode.getCode()); reply.setErrorMessage(errorCode.getCodeDesc()); reply.setContent(content); return reply; }
Example 5
Source File: Service.java From web3sdk with Apache License 2.0 | 5 votes |
public void onReceiveRegisterEventResponse(ChannelHandlerContext ctx, ChannelMessage2 message) { ChannelResponseCallback2 callback = (ChannelResponseCallback2) seq2Callback.get(message.getSeq()); String seq = message.getSeq(); String content = new String(message.getData()); if (callback == null) { logger.warn( " register event filter response cannot find callback, seq: {}, content: {}", seq, content); return; } seq2Callback.remove(seq); ChannelResponse response = new ChannelResponse(); response.setCtx(ctx); response.setErrorCode(message.getResult()); response.setMessageID(message.getSeq()); if (message.getData() != null) { response.setContent(message.getData()); } callback.onResponse(response); logger.info(" register event filter response, seq: {}, content: {} ", seq, content); }
Example 6
Source File: Service.java From web3sdk with Apache License 2.0 | 5 votes |
public void signForAmop(ChannelHandlerContext ctx, ChannelMessage2 message) throws IOException { SocketChannel socketChannel = (SocketChannel) ctx.channel(); logger.info( "sign ChannelResponse seq:{} msgtype:{} address:{} port:{}", message.getSeq(), message.getType(), socketChannel.remoteAddress().getAddress().getHostAddress(), socketChannel.remoteAddress().getPort()); logger.info( "sign request :{} length:{}", Arrays.toString(message.getData()), message.getLength()); String content = topicVerify.parseDataFromPush(message.getLength(), message.getData()); logger.info("content:{} content:{}", content, Arrays.toString(content.getBytes())); TopicVerifyReqProtocol topicVerifyProtocol = ObjectMapperFactory.getObjectMapper() .readValue(content, TopicVerifyReqProtocol.class); String randValue = topicVerifyProtocol.getRandValue(); String topic = topicVerifyProtocol.getTopic(); logger.info("sign rand_value:{} sign topic:{}", randValue, topic); String signature = topicVerify.signatureForRandValue(topic, randValue); TopicVerifyRespProtocol topicVerifyRespProtocol = new TopicVerifyRespProtocol(); topicVerifyRespProtocol.setSignature(signature); String jsonStr = ObjectMapperFactory.getObjectMapper().writeValueAsString(topicVerifyRespProtocol); logger.info("signature jsonStr result:{}", jsonStr); byte[] bytes = topicVerify.getByteBuffByString(message.getTopic(), jsonStr); ChannelResponse response = new ChannelResponse(); response.setMessageID(message.getSeq()); response.setErrorCode(0); response.setContent(bytes); sendResponseMessage2(response, ctx, message.getSeq(), message.getTopic()); }
Example 7
Source File: PushCallback2.java From web3sdk with Apache License 2.0 | 5 votes |
@Override public void onPush(ChannelPush push) { DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); logger.debug("push:" + push.getContent()); System.out.println(df.format(LocalDateTime.now()) + "server:push:" + push.getContent()); ChannelResponse response = new ChannelResponse(); response.setContent("receive request seq:" + String.valueOf(push.getMessageID())); response.setErrorCode(0); push.sendResponse(response); }
Example 8
Source File: AMOPSubscription.java From WeEvent with Apache License 2.0 | 4 votes |
private static ChannelResponse toChannelResponse(BrokerException e) { ChannelResponse reply = new ChannelResponse(); reply.setErrorCode(e.getCode()); reply.setContent(e.getMessage()); return reply; }
Example 9
Source File: AMOPChannel.java From WeEvent with Apache License 2.0 | 4 votes |
private static ChannelResponse toChannelResponse(BrokerException e) { ChannelResponse reply = new ChannelResponse(); reply.setErrorCode(e.getCode()); reply.setContent(e.getMessage()); return reply; }