Javadocs added for SCTP stuff
This commit is contained in:
parent
5a4a52a817
commit
6db7250ed9
@ -43,21 +43,41 @@ public final class SctpMessage {
|
|||||||
msgInfo = null;
|
msgInfo = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Essential data that is being carried within SCTP Data Chunk
|
||||||
|
* @param msgInfo the {@link MessageInfo}
|
||||||
|
* @param payloadBuffer channel buffer
|
||||||
|
*/
|
||||||
public SctpMessage(MessageInfo msgInfo, ByteBuf payloadBuffer) {
|
public SctpMessage(MessageInfo msgInfo, ByteBuf payloadBuffer) {
|
||||||
|
if (msgInfo == null) {
|
||||||
|
throw new NullPointerException("msgInfo");
|
||||||
|
}
|
||||||
|
if (payloadBuffer == null) {
|
||||||
|
throw new NullPointerException("payloadBuffer");
|
||||||
|
}
|
||||||
this.msgInfo = msgInfo;
|
this.msgInfo = msgInfo;
|
||||||
streamIdentifier = msgInfo.streamNumber();
|
streamIdentifier = msgInfo.streamNumber();
|
||||||
protocolIdentifier = msgInfo.payloadProtocolID();
|
protocolIdentifier = msgInfo.payloadProtocolID();
|
||||||
this.payloadBuffer = payloadBuffer;
|
this.payloadBuffer = payloadBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the stream-identifier
|
||||||
|
*/
|
||||||
public int getStreamIdentifier() {
|
public int getStreamIdentifier() {
|
||||||
return streamIdentifier;
|
return streamIdentifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the protocol-identifier
|
||||||
|
*/
|
||||||
public int getProtocolIdentifier() {
|
public int getProtocolIdentifier() {
|
||||||
return protocolIdentifier;
|
return protocolIdentifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a view of the readable bytes of the payload.
|
||||||
|
*/
|
||||||
public ByteBuf getPayloadBuffer() {
|
public ByteBuf getPayloadBuffer() {
|
||||||
if (payloadBuffer.readable()) {
|
if (payloadBuffer.readable()) {
|
||||||
return payloadBuffer.slice();
|
return payloadBuffer.slice();
|
||||||
@ -66,10 +86,17 @@ public final class SctpMessage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the {@link MessageInfo} for inbound messages or {@code null} for
|
||||||
|
* outbound messages.
|
||||||
|
*/
|
||||||
public MessageInfo getMessageInfo() {
|
public MessageInfo getMessageInfo() {
|
||||||
return msgInfo;
|
return msgInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return {@code true} if this message is complete.
|
||||||
|
*/
|
||||||
public boolean isComplete() {
|
public boolean isComplete() {
|
||||||
if (msgInfo != null) {
|
if (msgInfo != null) {
|
||||||
return msgInfo.isComplete();
|
return msgInfo.isComplete();
|
||||||
|
@ -16,12 +16,28 @@
|
|||||||
package io.netty.channel.socket;
|
package io.netty.channel.socket;
|
||||||
|
|
||||||
import com.sun.nio.sctp.Notification;
|
import com.sun.nio.sctp.Notification;
|
||||||
|
import io.netty.channel.ChannelHandler;
|
||||||
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
|
import io.netty.channel.ChannelPipeline;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Will be passed to {@link ChannelPipeline#fireUserEventTriggered(Object)} method and so forwarded to the added
|
||||||
|
* {@link ChannelHandler#userEventTriggered(ChannelHandlerContext, Object)} method.
|
||||||
|
*/
|
||||||
public final class SctpNotificationEvent {
|
public final class SctpNotificationEvent {
|
||||||
private final Notification notification;
|
private final Notification notification;
|
||||||
private final Object attachment;
|
private final Object attachment;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new instance
|
||||||
|
*
|
||||||
|
* @param notification the {@link Notification} which triggered this event
|
||||||
|
* @param attachment the attachment or {@code null} if non is attached.
|
||||||
|
*/
|
||||||
public SctpNotificationEvent(Notification notification, Object attachment) {
|
public SctpNotificationEvent(Notification notification, Object attachment) {
|
||||||
|
if (notification == null) {
|
||||||
|
throw new NullPointerException("notification");
|
||||||
|
}
|
||||||
this.notification = notification;
|
this.notification = notification;
|
||||||
this.attachment = attachment;
|
this.attachment = attachment;
|
||||||
}
|
}
|
||||||
|
@ -23,40 +23,50 @@ import com.sun.nio.sctp.PeerAddressChangeNotification;
|
|||||||
import com.sun.nio.sctp.SendFailedNotification;
|
import com.sun.nio.sctp.SendFailedNotification;
|
||||||
import com.sun.nio.sctp.ShutdownNotification;
|
import com.sun.nio.sctp.ShutdownNotification;
|
||||||
|
|
||||||
public class SctpNotificationHandler extends AbstractNotificationHandler<Object> {
|
import io.netty.channel.ChannelPipeline;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link AbstractNotificationHandler} implementation which will handle all {@link Notification}s by trigger a
|
||||||
|
* {@link SctpNotificationEvent} in the {@link ChannelPipeline} of a {@link SctpChannel}.
|
||||||
|
*/
|
||||||
|
public final class SctpNotificationHandler extends AbstractNotificationHandler<Object> {
|
||||||
|
|
||||||
private final SctpChannel sctpChannel;
|
private final SctpChannel sctpChannel;
|
||||||
|
|
||||||
public SctpNotificationHandler(SctpChannel sctpChannel) {
|
public SctpNotificationHandler(SctpChannel sctpChannel) {
|
||||||
|
if (sctpChannel == null) {
|
||||||
|
throw new NullPointerException("sctpChannel");
|
||||||
|
}
|
||||||
this.sctpChannel = sctpChannel;
|
this.sctpChannel = sctpChannel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HandlerResult handleNotification(AssociationChangeNotification notification, Object o) {
|
public HandlerResult handleNotification(AssociationChangeNotification notification, Object o) {
|
||||||
updateInboundBuffer(notification, o);
|
fireEvent(notification, o);
|
||||||
return HandlerResult.CONTINUE;
|
return HandlerResult.CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HandlerResult handleNotification(PeerAddressChangeNotification notification, Object o) {
|
public HandlerResult handleNotification(PeerAddressChangeNotification notification, Object o) {
|
||||||
updateInboundBuffer(notification, o);
|
fireEvent(notification, o);
|
||||||
return HandlerResult.CONTINUE;
|
return HandlerResult.CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HandlerResult handleNotification(SendFailedNotification notification, Object o) {
|
public HandlerResult handleNotification(SendFailedNotification notification, Object o) {
|
||||||
updateInboundBuffer(notification, o);
|
fireEvent(notification, o);
|
||||||
return HandlerResult.CONTINUE;
|
return HandlerResult.CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HandlerResult handleNotification(ShutdownNotification notification, Object o) {
|
public HandlerResult handleNotification(ShutdownNotification notification, Object o) {
|
||||||
updateInboundBuffer(notification, o);
|
fireEvent(notification, o);
|
||||||
sctpChannel.close();
|
sctpChannel.close();
|
||||||
return HandlerResult.RETURN;
|
return HandlerResult.RETURN;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateInboundBuffer(Notification notification, Object o) {
|
private void fireEvent(Notification notification, Object o) {
|
||||||
sctpChannel.pipeline().fireUserEventTriggered(new SctpNotificationEvent(notification, o));
|
sctpChannel.pipeline().fireUserEventTriggered(new SctpNotificationEvent(notification, o));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user