当前位置: 首页>>代码示例>>Java>>正文


Java AttributeMap类代码示例

本文整理汇总了Java中io.netty.util.AttributeMap的典型用法代码示例。如果您正苦于以下问题:Java AttributeMap类的具体用法?Java AttributeMap怎么用?Java AttributeMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AttributeMap类属于io.netty.util包,在下文中一共展示了AttributeMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: decode

import io.netty.util.AttributeMap; //导入依赖的package包/类
@Override
void decode(AttributeMap ctx, ByteBuf in, List<Object> out) throws Exception {
    in.resetReaderIndex();
    //Common decoding part
    ConnAckMessage message = new ConnAckMessage();
    if (!decodeCommonHeader(message, 0x00, in)) {
        in.resetReaderIndex();
        return;
    }
    //skip reserved byte
    in.skipBytes(1);
    
    //read  return code
    message.setReturnCode(in.readByte());
    out.add(message);
}
 
开发者ID:sn3009,项目名称:EasyMessage,代码行数:17,代码来源:ConnAckDecoder.java

示例2: toTransportException

import io.netty.util.AttributeMap; //导入依赖的package包/类
private static TransportException toTransportException(
    Throwable cause, AttributeMap channelAttrs) {
  String service = channelAttrs.attr(ChannelAttributes.SERVICE).get();
  String procedure = channelAttrs.attr(ChannelAttributes.PROCEDURE).get();
  if (cause instanceof DeadlineExceededException) {
    // A DeadlineExceededException on inbound translates to a TimeoutException on the caller
    String caller = channelAttrs.attr(ChannelAttributes.CALLER).get();
    Instant start = channelAttrs.attr(ChannelAttributes.REQUEST_START).get();
    Instant end = ((DeadlineExceededException) cause).getTimeExceeded();
    long timeSpent = start != null ? Duration.between(start, end).toMillis() : -1;
    return new TimeoutException(service, procedure, caller, timeSpent);
  }
  if (isRemoteException(cause)) {
    // Remote exceptions do not bubble up to the caller
    return UnexpectedException.wrap(cause, service, procedure);
  }
  if (cause instanceof TransportException) {
    return (TransportException) cause;
  }
  log.warn(
      "Caught unexpected error in procedure \"{}\" of service \"{}\"", procedure, service, cause);
  return UnexpectedException.wrap(cause, service, procedure);
}
 
开发者ID:yarpc,项目名称:yarpc-java,代码行数:24,代码来源:ErrorResponseEncoder.java

示例3: decode

import io.netty.util.AttributeMap; //导入依赖的package包/类
@Override
void decode(AttributeMap ctx, ByteBuf in, List<Object> out) throws Exception {
    in.resetReaderIndex();
    //Common decoding part
    ConnAckMessage message = new ConnAckMessage();
    if (!decodeCommonHeader(message, 0x00, in)) {
        in.resetReaderIndex();
        return;
    }
    //skip reserved byte
    in.skipBytes(1);

    //read  return code
    message.setReturnCode(in.readByte());
    out.add(message);
}
 
开发者ID:wso2,项目名称:andes,代码行数:17,代码来源:ConnAckDecoder.java

示例4: decode

import io.netty.util.AttributeMap; //导入依赖的package包/类
@Override
public SubscribeMessage decode(AttributeMap ctx, ByteBuf in) throws Exception
{
    //Common decoding part
    SubscribeMessage message = new SubscribeMessage();
    in.resetReaderIndex();
    if (!decodeCommonHeader(message, 0x02, in)) {
        in.resetReaderIndex();
        return null;
    }

    //check qos level
    if (message.getQos() != AbstractMessage.QOSType.LEAST_ONE) {
        throw new CorruptedFrameException("Received SUBSCRIBE message with QoS other than LEAST_ONE, was: " + message.getQos());
    }

    int start = in.readerIndex();
    //read  messageIDs
    message.setMessageID(in.readUnsignedShort());
    int read = in.readerIndex() - start;
    while (read < message.getRemainingLength()) {
        decodeSubscription(in, message);
        read = in.readerIndex() - start;
    }

    if (message.subscriptions().isEmpty()) {
        throw new CorruptedFrameException("subscribe MUST have got at least 1 couple topic/QoS");
    }

    return message;
}
 
开发者ID:sylvek,项目名称:websocket-mqtt-forwarder,代码行数:32,代码来源:SubscribeDecoder.java

示例5: decode

import io.netty.util.AttributeMap; //导入依赖的package包/类
@Override
void decode(AttributeMap ctx, ByteBuf in, List<Object> out) throws Exception {
    //Common decoding part
    in.resetReaderIndex();
    DisconnectMessage message = new DisconnectMessage();
    if (!decodeCommonHeader(message, 0x00, in)) {
        in.resetReaderIndex();
        return;
    }
    out.add(message);
}
 
开发者ID:sn3009,项目名称:EasyMessage,代码行数:12,代码来源:DisconnectDecoder.java

示例6: decode

import io.netty.util.AttributeMap; //导入依赖的package包/类
@Override
void decode(AttributeMap ctx, ByteBuf in, List<Object> out) throws UnsupportedEncodingException {
    in.resetReaderIndex();
    //Common decoding part
    MessageIDMessage message = new PubRelMessage();
    if (!decodeCommonHeader(message, 0x02, in)) {
        in.resetReaderIndex();
        return;
    }
    
    //read  messageIDs
    message.setMessageID(in.readUnsignedShort());
    out.add(message);
}
 
开发者ID:sn3009,项目名称:EasyMessage,代码行数:15,代码来源:PubRelDecoder.java

示例7: decode

import io.netty.util.AttributeMap; //导入依赖的package包/类
@Override
void decode(AttributeMap ctx, ByteBuf in, List<Object> out) throws Exception {
    //Common decoding part
    in.resetReaderIndex();
    PingRespMessage message = new PingRespMessage();
    if (!decodeCommonHeader(message, 0x00, in)) {
        in.resetReaderIndex();
        return;
    }
    out.add(message);
}
 
开发者ID:sn3009,项目名称:EasyMessage,代码行数:12,代码来源:PingRespDecoder.java

示例8: decode

import io.netty.util.AttributeMap; //导入依赖的package包/类
@Override
void decode(AttributeMap ctx, ByteBuf in, List<Object> out) throws Exception {
    //Common decoding part
    in.resetReaderIndex();
    PingReqMessage message = new PingReqMessage();
    if (!decodeCommonHeader(message, 0x00, in)) {
        in.resetReaderIndex();
        return;
    }
    out.add(message);
}
 
开发者ID:sn3009,项目名称:EasyMessage,代码行数:12,代码来源:PingReqDecoder.java

示例9: decode

import io.netty.util.AttributeMap; //导入依赖的package包/类
@Override
void decode(AttributeMap ctx, ByteBuf in, List<Object> out) throws Exception {
    //Common decoding part
    in.resetReaderIndex();
    UnsubscribeMessage message = new UnsubscribeMessage();
    if (!decodeCommonHeader(message, 0x02, in)) {
        in.resetReaderIndex();
        return;
    }
    
    //check qos level
    if (message.getQos() != AbstractMessage.QOSType.LEAST_ONE) {
        throw new CorruptedFrameException("Found an Unsubscribe message with qos other than LEAST_ONE, was: " + message.getQos());
    }
        
    int start = in.readerIndex();
    //read  messageIDs
    message.setMessageID(in.readUnsignedShort());
    int read = in.readerIndex() - start;
    while (read < message.getRemainingLength()) {
        String topicFilter = Utils.decodeString(in);
        //check topic is at least one char [MQTT-4.7.3-1]
        if (topicFilter.length() == 0) {
            throw new CorruptedFrameException("Received an UNSUBSCRIBE with empty topic filter");
        }
        message.addTopicFilter(topicFilter);
        read = in.readerIndex() - start;
    }
    if (message.topicFilters().isEmpty()) {
        throw new CorruptedFrameException("unsubscribe MUST have got at least 1 topic");
    }
    out.add(message);
}
 
开发者ID:sn3009,项目名称:EasyMessage,代码行数:34,代码来源:UnsubscribeDecoder.java

示例10: decode

import io.netty.util.AttributeMap; //导入依赖的package包/类
@Override
void decode(AttributeMap ctx, ByteBuf in, List<Object> out) throws Exception {
    //Common decoding part
    SubscribeMessage message = new SubscribeMessage();
    in.resetReaderIndex();
    if (!decodeCommonHeader(message, 0x02, in)) {
        in.resetReaderIndex();
        return;
    }
    
    //check qos level
    if (message.getQos() != QOSType.LEAST_ONE) {
        throw new CorruptedFrameException("Received SUBSCRIBE message with QoS other than LEAST_ONE, was: " + message.getQos());
    }
        
    int start = in.readerIndex();
    //read  messageIDs
    message.setMessageID(in.readUnsignedShort());
    int read = in.readerIndex() - start;
    while (read < message.getRemainingLength()) {
        decodeSubscription(in, message);
        read = in.readerIndex() - start;
    }
    
    if (message.subscriptions().isEmpty()) {
        throw new CorruptedFrameException("subscribe MUST have got at least 1 couple topic/QoS");
    } 
    
    out.add(message);
}
 
开发者ID:sn3009,项目名称:EasyMessage,代码行数:31,代码来源:SubscribeDecoder.java

示例11: isMQTT3_1_1

import io.netty.util.AttributeMap; //导入依赖的package包/类
static boolean isMQTT3_1_1(AttributeMap attrsMap) {
    Attribute<Integer> versionAttr = attrsMap.attr(MQTTDecoder.PROTOCOL_VERSION);
    Integer protocolVersion = versionAttr.get();
    if (protocolVersion == null) {
        return true;
    } 
    return protocolVersion == VERSION_3_1_1;
}
 
开发者ID:sn3009,项目名称:EasyMessage,代码行数:9,代码来源:Utils.java

示例12: decode

import io.netty.util.AttributeMap; //导入依赖的package包/类
@Override
void decode(AttributeMap ctx, ByteBuf in, List<Object> out) throws Exception {
    in.resetReaderIndex();
    //Common decoding part
    MessageIDMessage message = createMessage();
    if (!decodeCommonHeader(message, 0x00, in)) {
        in.resetReaderIndex();
        return;
    }
    
    //read  messageIDs
    message.setMessageID(in.readUnsignedShort());
    out.add(message);
}
 
开发者ID:sn3009,项目名称:EasyMessage,代码行数:15,代码来源:MessageIDDecoder.java

示例13: decode

import io.netty.util.AttributeMap; //导入依赖的package包/类
@Override
void decode(AttributeMap ctx, ByteBuf in, List<Object> out) throws Exception {
    //Common decoding part
    in.resetReaderIndex();
    SubAckMessage message = new SubAckMessage();
    if (!decodeCommonHeader(message, 0x00, in)) {
        in.resetReaderIndex();
        return;
    }
    int remainingLength = message.getRemainingLength();
    
    //MessageID
    message.setMessageID(in.readUnsignedShort());
    remainingLength -= 2;
    
    //Qos array
    if (in.readableBytes() < remainingLength ) {
        in.resetReaderIndex();
        return;
    }
    for (int i = 0; i < remainingLength; i++) {
        byte qos = in.readByte();
        message.addType(AbstractMessage.QOSType.valueOf(qos));
    }
    
    out.add(message);
}
 
开发者ID:sn3009,项目名称:EasyMessage,代码行数:28,代码来源:SubAckDecoder.java

示例14: buildStartMessage

import io.netty.util.AttributeMap; //导入依赖的package包/类
@Override
public HttpRequest buildStartMessage(TransportRequest request, AttributeMap channelAttrs) {
  DefaultHttpRequest httpRequest =
      new DefaultHttpRequest(HttpTransport.HTTP_VERSION, HttpMethod.POST, url.getPath());
  HttpHeaders httpHeaders = httpRequest.headers();
  setCommonHeaders(httpHeaders, request, channelAttrs);
  httpHeaders.set(HttpHeaderNames.TRANSFER_ENCODING, HttpHeaderValues.CHUNKED);
  return httpRequest;
}
 
开发者ID:yarpc,项目名称:yarpc-java,代码行数:10,代码来源:TransportRequestEncoderConfiguration.java

示例15: buildFullMessage

import io.netty.util.AttributeMap; //导入依赖的package包/类
@Override
public HttpRequest buildFullMessage(
    TransportRequest request, byte[] body, AttributeMap channelAttrs) {
  DefaultHttpRequest httpRequest =
      new DefaultFullHttpRequest(
          HttpTransport.HTTP_VERSION,
          HttpMethod.POST,
          url.getPath(),
          Unpooled.wrappedBuffer(body));
  setCommonHeaders(httpRequest.headers(), request, channelAttrs);
  HttpUtil.setContentLength(httpRequest, body.length);
  return httpRequest;
}
 
开发者ID:yarpc,项目名称:yarpc-java,代码行数:14,代码来源:TransportRequestEncoderConfiguration.java


注:本文中的io.netty.util.AttributeMap类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。