Java Code Examples for io.netty.channel.AddressedEnvelope#recipient()
The following examples show how to use
io.netty.channel.AddressedEnvelope#recipient() .
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: DnsMessageUtil.java From netty-4.1.22 with Apache License 2.0 | 6 votes |
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; }
Example 2
Source File: DatagramDnsResponseEncoder.java From netty-4.1.22 with Apache License 2.0 | 6 votes |
@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)); }
Example 3
Source File: DatagramDnsQueryEncoder.java From netty-4.1.22 with Apache License 2.0 | 6 votes |
@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)); }
Example 4
Source File: DatagramDnsQuery.java From netty-4.1.22 with Apache License 2.0 | 5 votes |
@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; }
Example 5
Source File: DatagramDnsResponse.java From netty-4.1.22 with Apache License 2.0 | 5 votes |
@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; }
Example 6
Source File: DatagramPacketEncoder.java From netty-4.1.22 with Apache License 2.0 | 5 votes |
@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; }