Class SseSubscription

java.lang.Object
io.github.easy4j.opencode.api.sse.SseSubscription
All Implemented Interfaces:
AutoCloseable

public final class SseSubscription extends Object implements AutoCloseable
可取消且幂等关闭的 OpenCode SSE 订阅句柄。
Since:
1.0.0
Author:
Loong Wan
  • Constructor Summary

    Constructors
    Constructor
    Description
    SseSubscription(Runnable cancellation)
    创建 sse subscription 实例,并按传入依赖确定资源所有权。
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    取消当前异步操作或 SSE 订阅。
    void
    释放当前对象持有的连接、订阅或执行资源;重复调用是安全的。
    boolean
    判断当前订阅是否仍可接收事件。

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SseSubscription

      public SseSubscription(Runnable cancellation)
      创建 sse subscription 实例,并按传入依赖确定资源所有权。
      Parameters:
      cancellation - 取消信号;为 null 时不可由外部取消
  • Method Details

    • cancel

      public boolean cancel()
      取消当前异步操作或 SSE 订阅。
      Returns:
      操作成功返回 true,否则返回 false
    • isActive

      public boolean isActive()
      判断当前订阅是否仍可接收事件。
      Returns:
      满足条件返回 true,否则返回 false
    • close

      public void close()
      释放当前对象持有的连接、订阅或执行资源;重复调用是安全的。
      Specified by:
      close in interface AutoCloseable