io.netty.channel.AddressedEnvelope#recipient ( )源码实例Demo

下面列出了io.netty.channel.AddressedEnvelope#recipient ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: netty-4.1.22   文件: DnsMessageUtil.java
private static StringBuilder appendAddresses(StringBuilder buf, DnsMessage msg) {

        if (!(msg instanceof AddressedEnvelope)) {
            return buf;
        }

        @SuppressWarnings("unchecked")
        AddressedEnvelope<?, SocketAddress> envelope = (AddressedEnvelope<?, SocketAddress>) msg;

        SocketAddress addr = envelope.sender();
        if (addr != null) {
            buf.append("from: ")
               .append(addr)
               .append(", ");
        }

        addr = envelope.recipient();
        if (addr != null) {
            buf.append("to: ")
               .append(addr)
               .append(", ");
        }

        return buf;
    }
 
源代码2 项目: netty-4.1.22   文件: DatagramDnsResponseEncoder.java
@Override
protected void encode(ChannelHandlerContext ctx,
                      AddressedEnvelope<DnsResponse, InetSocketAddress> in, List<Object> out) throws Exception {

    final InetSocketAddress recipient = in.recipient();
    final DnsResponse response = in.content();
    final ByteBuf buf = allocateBuffer(ctx, in);

    boolean success = false;
    try {
        encodeHeader(response, buf);
        encodeQuestions(response, buf);
        encodeRecords(response, DnsSection.ANSWER, buf);
        encodeRecords(response, DnsSection.AUTHORITY, buf);
        encodeRecords(response, DnsSection.ADDITIONAL, buf);
        success = true;
    } finally {
        if (!success) {
            buf.release();
        }
    }

    out.add(new DatagramPacket(buf, recipient, null));
}
 
源代码3 项目: netty-4.1.22   文件: DatagramDnsQueryEncoder.java
@Override
protected void encode(
    ChannelHandlerContext ctx,
    AddressedEnvelope<DnsQuery, InetSocketAddress> in, List<Object> out) throws Exception {

    final InetSocketAddress recipient = in.recipient();
    final DnsQuery query = in.content();
    final ByteBuf buf = allocateBuffer(ctx, in);

    boolean success = false;
    try {
        encodeHeader(query, buf);
        encodeQuestions(query, buf);
        encodeRecords(query, DnsSection.ADDITIONAL, buf);
        success = true;
    } finally {
        if (!success) {
            buf.release();
        }
    }

    out.add(new DatagramPacket(buf, recipient, null));
}
 
源代码4 项目: netty-4.1.22   文件: DatagramDnsQuery.java
@Override
public boolean equals(Object obj) {
    if (this == obj) {
        return true;
    }

    if (!super.equals(obj)) {
        return false;
    }

    if (!(obj instanceof AddressedEnvelope)) {
        return false;
    }

    @SuppressWarnings("unchecked")
    final AddressedEnvelope<?, SocketAddress> that = (AddressedEnvelope<?, SocketAddress>) obj;
    if (sender() == null) {
        if (that.sender() != null) {
            return false;
        }
    } else if (!sender().equals(that.sender())) {
        return false;
    }

    if (recipient() == null) {
        if (that.recipient() != null) {
            return false;
        }
    } else if (!recipient().equals(that.recipient())) {
        return false;
    }

    return true;
}
 
源代码5 项目: netty-4.1.22   文件: DatagramDnsResponse.java
@Override
public boolean equals(Object obj) {
    if (this == obj) {
        return true;
    }

    if (!super.equals(obj)) {
        return false;
    }

    if (!(obj instanceof AddressedEnvelope)) {
        return false;
    }

    @SuppressWarnings("unchecked")
    final AddressedEnvelope<?, SocketAddress> that = (AddressedEnvelope<?, SocketAddress>) obj;
    if (sender() == null) {
        if (that.sender() != null) {
            return false;
        }
    } else if (!sender().equals(that.sender())) {
        return false;
    }

    if (recipient() == null) {
        if (that.recipient() != null) {
            return false;
        }
    } else if (!recipient().equals(that.recipient())) {
        return false;
    }

    return true;
}
 
源代码6 项目: netty-4.1.22   文件: DatagramPacketEncoder.java
@Override
public boolean acceptOutboundMessage(Object msg) throws Exception {
    if (super.acceptOutboundMessage(msg)) {
        @SuppressWarnings("rawtypes")
        AddressedEnvelope envelope = (AddressedEnvelope) msg;
        return encoder.acceptOutboundMessage(envelope.content())
                && envelope.sender() instanceof InetSocketAddress
                && envelope.recipient() instanceof InetSocketAddress;
    }
    return false;
}