@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 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 protected void decode(ChannelHandlerContext ctx, SctpMessage msg, List<Object> out) throws Exception { if (!msg.isComplete()) { throw new CodecException(String.format("Received SctpMessage is not complete, please add %s in the " + "pipeline before this handler", SctpMessageCompletionHandler.class.getSimpleName())); } out.add(msg.content().retain()); } }
@Override protected void decode(ChannelHandlerContext ctx, SctpMessage msg, List<Object> out) throws Exception { final ByteBuf byteBuf = msg.content(); final int protocolIdentifier = msg.protocolIdentifier(); final int streamIdentifier = msg.streamIdentifier();
ByteBuf data = packet.content(); int dataLen = data.readableBytes(); ByteBuffer nioData;
@Override protected final Object filterOutboundMessage(Object msg) throws Exception { if (msg instanceof SctpMessage) { SctpMessage m = (SctpMessage) msg; ByteBuf buf = m.content(); if (buf.isDirect() && buf.nioBufferCount() == 1) { return m; } return new SctpMessage(m.protocolIdentifier(), m.streamIdentifier(), m.isUnordered(), newDirectBuffer(m, buf)); } throw new UnsupportedOperationException( "unsupported message type: " + StringUtil.simpleClassName(msg) + " (expected: " + StringUtil.simpleClassName(SctpMessage.class)); }
@Override protected boolean doWriteMessage(Object msg, ChannelOutboundBuffer in) throws Exception { SctpMessage packet = (SctpMessage) msg; ByteBuf data = packet.content(); int dataLen = data.readableBytes(); if (dataLen == 0) { return true; } ByteBufAllocator alloc = alloc(); boolean needsCopy = data.nioBufferCount() != 1; if (!needsCopy) { if (!data.isDirect() && alloc.isDirectBufferPooled()) { needsCopy = true; } } ByteBuffer nioData; if (needsCopy) { data = alloc.directBuffer(dataLen).writeBytes(data); } nioData = data.nioBuffer(); final MessageInfo mi = MessageInfo.createOutgoing(association(), null, packet.streamIdentifier()); mi.payloadProtocolID(packet.protocolIdentifier()); mi.streamNumber(packet.streamIdentifier()); mi.unordered(packet.isUnordered()); final int writtenBytes = javaChannel().send(nioData, mi); return writtenBytes > 0; }
@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 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 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 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 protected void decode(ChannelHandlerContext ctx, SctpMessage msg, List<Object> out) throws Exception { if (!msg.isComplete()) { throw new CodecException(String.format("Received SctpMessage is not complete, please add %s in the " + "pipeline before this handler", SctpMessageCompletionHandler.class.getSimpleName())); } out.add(msg.content().retain()); } }
@Override protected void decode(ChannelHandlerContext ctx, SctpMessage msg, List<Object> out) throws Exception { if (!msg.isComplete()) { throw new CodecException(String.format("Received SctpMessage is not complete, please add %s in the " + "pipeline before this handler", SctpMessageCompletionHandler.class.getSimpleName())); } out.add(msg.content().retain()); } }
@Override protected void decode(ChannelHandlerContext ctx, SctpMessage msg, List<Object> out) throws Exception { final ByteBuf byteBuf = msg.content(); final int protocolIdentifier = msg.protocolIdentifier(); final int streamIdentifier = msg.streamIdentifier();
@Override protected void decode(ChannelHandlerContext ctx, SctpMessage msg, List<Object> out) throws Exception { final ByteBuf byteBuf = msg.content(); final int protocolIdentifier = msg.protocolIdentifier(); final int streamIdentifier = msg.streamIdentifier();
@Override public void channelRead(ChannelHandlerContext ctx, Object msg) { // try { PayloadData payload; if (this.association.getIpChannelType() == IpChannelType.SCTP) { SctpMessage sctpMessage = (SctpMessage) msg; ByteBuf byteBuf = sctpMessage.content(); payload = new PayloadData(byteBuf.readableBytes(), byteBuf, sctpMessage.isComplete(), sctpMessage.isUnordered(), sctpMessage.protocolIdentifier(), sctpMessage.streamIdentifier()); } else { ByteBuf byteBuf = (ByteBuf) msg; payload = new PayloadData(byteBuf.readableBytes(), byteBuf, true, false, 0, 0); } if (logger.isDebugEnabled()) { logger.debug(String.format("Rx : Ass=%s %s", this.association.getName(), payload)); } this.association.read(payload); // } finally { // ReferenceCountUtil.release(msg); // } }
@Override protected final Object filterOutboundMessage(Object msg) throws Exception { if (msg instanceof SctpMessage) { SctpMessage m = (SctpMessage) msg; ByteBuf buf = m.content(); if (buf.isDirect() && buf.nioBufferCount() == 1) { return m; } return new SctpMessage(m.protocolIdentifier(), m.streamIdentifier(), m.isUnordered(), newDirectBuffer(m, buf)); } throw new UnsupportedOperationException( "unsupported message type: " + StringUtil.simpleClassName(msg) + " (expected: " + StringUtil.simpleClassName(SctpMessage.class)); }
@Override protected final Object filterOutboundMessage(Object msg) throws Exception { if (msg instanceof SctpMessage) { SctpMessage m = (SctpMessage) msg; ByteBuf buf = m.content(); if (buf.isDirect() && buf.nioBufferCount() == 1) { return m; } return new SctpMessage(m.protocolIdentifier(), m.streamIdentifier(), m.isUnordered(), newDirectBuffer(m, buf)); } throw new UnsupportedOperationException( "unsupported message type: " + StringUtil.simpleClassName(msg) + " (expected: " + StringUtil.simpleClassName(SctpMessage.class)); }
@Override protected boolean doWriteMessage(Object msg, ChannelOutboundBuffer in) throws Exception { SctpMessage packet = (SctpMessage) msg; ByteBuf data = packet.content(); int dataLen = data.readableBytes(); if (dataLen == 0) { return true; } ByteBufAllocator alloc = alloc(); boolean needsCopy = data.nioBufferCount() != 1; if (!needsCopy) { if (!data.isDirect() && alloc.isDirectBufferPooled()) { needsCopy = true; } } ByteBuffer nioData; if (needsCopy) { data = alloc.directBuffer(dataLen).writeBytes(data); } nioData = data.nioBuffer(); final MessageInfo mi = MessageInfo.createOutgoing(association(), null, packet.streamIdentifier()); mi.payloadProtocolID(packet.protocolIdentifier()); mi.streamNumber(packet.streamIdentifier()); mi.unordered(packet.isUnordered()); final int writtenBytes = javaChannel().send(nioData, mi); return writtenBytes > 0; }
@Override protected boolean doWriteMessage(Object msg, ChannelOutboundBuffer in) throws Exception { SctpMessage packet = (SctpMessage) msg; ByteBuf data = packet.content(); int dataLen = data.readableBytes(); if (dataLen == 0) { return true; } ByteBufAllocator alloc = alloc(); boolean needsCopy = data.nioBufferCount() != 1; if (!needsCopy) { if (!data.isDirect() && alloc.isDirectBufferPooled()) { needsCopy = true; } } ByteBuffer nioData; if (needsCopy) { data = alloc.directBuffer(dataLen).writeBytes(data); } nioData = data.nioBuffer(); final MessageInfo mi = MessageInfo.createOutgoing(association(), null, packet.streamIdentifier()); mi.payloadProtocolID(packet.protocolIdentifier()); mi.streamNumber(packet.streamIdentifier()); mi.unordered(packet.isUnordered()); final int writtenBytes = javaChannel().send(nioData, mi); return writtenBytes > 0; }