Module jdk.sctp
Package com.sun.nio.sctp

Interface NotificationHandler<T>

类型参数:
T - 附加到接收操作的对象的类型
所有已知实现类:
AbstractNotificationHandler

public interface NotificationHandler<T>
用于消费来自SCTP堆栈的通知的处理程序。

此包中定义的SCTP通道允许指定通知处理程序以消费来自SCTP堆栈的通知。当接收到通知时,将调用处理程序的handleNotification方法来处理该通知。

此外,可以附加附件对象到receive操作,以在消费通知时提供上下文。在使用无状态的NotificationHandler消费多个receive操作的结果时,附件非常重要。

鼓励处理程序实现扩展实现此接口并提供特定于通知的方法的AbstractNotificationHandler类。但是,API通常应该使用此处理程序接口作为参数、返回类型等的类型,而不是抽象类。

自版本:
1.7
  • Method Details

    • handleNotification

      HandlerResult handleNotification(Notification notification, T attachment)
      当从SCTP堆栈接收到通知时调用。
      参数:
      notification - 通知
      attachment - 在启动接收操作时附加到该操作的对象。
      返回:
      处理程序结果