Package net.voidnote

Class StreamHandle

java.lang.Object
net.voidnote.StreamHandle

public final class StreamHandle extends Object
A live Void Stream. Write encrypted messages and close() to self-destruct. Obtained from VoidNote.createStream(StreamOptions).

 StreamHandle stream = VoidNote.createStream(StreamOptions.of("vn_..."));
 System.out.println(stream.url);   // share this before writing

 stream.write("Deployment starting...");
 stream.write("Build complete — 47/47 passed");
 stream.close();
 
  • Field Details

    • url

      public final String url
      Shareable URL. Share this with viewers before writing messages.
    • expiresAt

      public final String expiresAt
      ISO 8601 expiry timestamp.
  • Method Details

    • write

      public void write(String content) throws VoidNoteException
      Encrypts content client-side and pushes it to the stream. The server never sees the plaintext.
      Throws:
      VoidNoteException
    • close

      public void close() throws VoidNoteException
      Closes the stream. Viewers receive a closed event and all content self-destructs.
      Throws:
      VoidNoteException
    • watch

      public void watch(Consumer<String> onMessage) throws VoidNoteException
      Subscribes to this stream, calling onMessage for each decrypted event. Blocks until the stream is closed or an unrecoverable error occurs. Automatically reconnects on connection drop using SSE Last-Event-ID.

      To run non-blocking, wrap in a thread:

      
       Thread.ofVirtual().start(() -> stream.watch(msg -> System.out.println(msg)));
       
      Throws:
      VoidNoteException