@Override public HandlerResult handleNotification(SendFailedNotification notification, Object o) { fireEvent(notification); return HandlerResult.CONTINUE; }
@Override public String toString() { return "SctpFrame{" + "streamIdentifier=" + streamIdentifier + ", protocolIdentifier=" + protocolIdentifier + ", unordered=" + unordered + ", data=" + contentToString() + '}'; } }
@Override public <T> boolean setOption(ChannelOption<T> option, T value) { validate(option, value); if (option == SO_RCVBUF) { setReceiveBufferSize((Integer) value); } else if (option == SO_SNDBUF) { setSendBufferSize((Integer) value); } else if (option == SCTP_NODELAY) { setSctpNoDelay((Boolean) value); } else if (option == SCTP_INIT_MAXSTREAMS) { setInitMaxStreams((SctpStandardSocketOptions.InitMaxStreams) value); } else { return super.setOption(option, value); } return true; }
@Override public <T> boolean setOption(ChannelOption<T> option, T value) { validate(option, value); if (option == ChannelOption.SO_RCVBUF) { setReceiveBufferSize((Integer) value); } else if (option == ChannelOption.SO_SNDBUF) { setSendBufferSize((Integer) value); } else if (option == SctpChannelOption.SCTP_INIT_MAXSTREAMS) { setInitMaxStreams((SctpStandardSocketOptions.InitMaxStreams) value); } else { return super.setOption(option, value); } return true; }
protected boolean acceptInboundMessage(SctpMessage msg) { return msg.protocolIdentifier() == protocolIdentifier && msg.streamIdentifier() == streamIdentifier; }
@SuppressWarnings("unchecked") @Override public <T> T getOption(ChannelOption<T> option) { if (option == ChannelOption.SO_RCVBUF) { return (T) Integer.valueOf(getReceiveBufferSize()); } if (option == ChannelOption.SO_SNDBUF) { return (T) Integer.valueOf(getSendBufferSize()); } if (option == SctpChannelOption.SCTP_INIT_MAXSTREAMS) { return (T) getInitMaxStreams(); } return super.getOption(option); }
@Override protected void doBind(SocketAddress localAddress) throws Exception { javaChannel().bind(localAddress, config.getBacklog()); }
private void fireEvent(Notification notification) { sctpChannel.pipeline().fireUserEventTriggered(notification); } }
@Override public SctpMessage replace(ByteBuf content) { if (msgInfo == null) { return new SctpMessage(protocolIdentifier, streamIdentifier, unordered, content); } else { return new SctpMessage(msgInfo, content); } }
@Override public int hashCode() { int result = streamIdentifier; result = 31 * result + protocolIdentifier; // values 1231 and 1237 are referenced in the javadocs of Boolean#hashCode() result = 31 * result + (unordered ? 1231 : 1237); result = 31 * result + content().hashCode(); return result; }
@Override protected void doBind(SocketAddress localAddress) throws Exception { sch.bind(localAddress, config.getBacklog()); }
public DefaultSctpChannelConfig(io.netty.channel.sctp.SctpChannel channel, SctpChannel javaChannel) { super(channel); if (javaChannel == null) { throw new NullPointerException("javaChannel"); } this.javaChannel = javaChannel; // Enable TCP_NODELAY by default if possible. if (PlatformDependent.canEnableTcpNoDelayByDefault()) { try { setSctpNoDelay(true); } catch (Exception e) { // Ignore. } } }
@Override public boolean acceptInboundMessage(Object msg) throws Exception { if (msg instanceof SctpMessage) { SctpMessage sctpMsg = (SctpMessage) msg; if (sctpMsg.isComplete()) { return true; } throw new CodecException(String.format("Received SctpMessage is not complete, please add %s in " + "the pipeline before this handler", SctpMessageCompletionHandler.class.getSimpleName())); } else { return false; } } }
@Override public Map<ChannelOption<?>, Object> getOptions() { return getOptions( super.getOptions(), SO_RCVBUF, SO_SNDBUF, SCTP_NODELAY, SCTP_INIT_MAXSTREAMS); }
@Override public Map<ChannelOption<?>, Object> getOptions() { return getOptions( super.getOptions(), ChannelOption.SO_RCVBUF, ChannelOption.SO_SNDBUF, SctpChannelOption.SCTP_INIT_MAXSTREAMS); }
@Override protected void encode(ChannelHandlerContext ctx, ByteBuf msg, List<Object> out) throws Exception { out.add(new SctpMessage(protocolIdentifier, streamIdentifier, unordered, msg.retain())); } }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } SctpMessage sctpFrame = (SctpMessage) o; if (protocolIdentifier != sctpFrame.protocolIdentifier) { return false; } if (streamIdentifier != sctpFrame.streamIdentifier) { return false; } if (unordered != sctpFrame.unordered) { return false; } return content().equals(sctpFrame.content()); }
@Override public HandlerResult handleNotification(AssociationChangeNotification notification, Object o) { fireEvent(notification); return HandlerResult.CONTINUE; }
@Override public HandlerResult handleNotification(PeerAddressChangeNotification notification, Object o) { fireEvent(notification); return HandlerResult.CONTINUE; }