Class StreamController

java.lang.Object
ai.mindconnect.adminui.controller.StreamController

@RestController @RequestMapping("/admin/api/streams") public class StreamController extends Object
Generic API over the ActiveStreams registry. Three endpoints, channel-id-keyed, JSON-only — no SSE-specific semantics. Any feature that registers a stream in the registry shows up here automatically.
  • GET /admin/api/streams — list all currently live streams.
  • GET /admin/api/streams/{channelId} — single-stream lookup, 404 if not running.
  • DELETE /admin/api/streams/{channelId} — cooperatively cancel the named stream.

The chat-page renderer uses the single-stream lookup to decide between rendering the Send and Stop button. UIs that show a global "what's running?" indicator would use the list endpoint.

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.springframework.http.ResponseEntity<Void>
    cancel(String channelId)
    Cooperatively cancels the named stream. 204 if a cancel was dispatched (the stream was running and accepted the signal), 404 if no such stream is registered.
    org.springframework.http.ResponseEntity<Map<String,Object>>
    get(String channelId)
     
    org.springframework.http.ResponseEntity<List<Map<String,Object>>>
     
    org.springframework.http.ResponseEntity<org.springframework.web.servlet.mvc.method.annotation.SseEmitter>
    resume(String channelId, long lastSeq)
    Reconnect endpoint.

    Methods inherited from class java.lang.Object

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

    • StreamController

      @Autowired public StreamController(ActiveStreams activeStreams)
  • Method Details

    • list

      @GetMapping public org.springframework.http.ResponseEntity<List<Map<String,Object>>> list()
    • get

      @GetMapping("/{channelId}") public org.springframework.http.ResponseEntity<Map<String,Object>> get(@PathVariable String channelId)
    • cancel

      @DeleteMapping("/{channelId}") public org.springframework.http.ResponseEntity<Void> cancel(@PathVariable String channelId)
      Cooperatively cancels the named stream. 204 if a cancel was dispatched (the stream was running and accepted the signal), 404 if no such stream is registered.
    • resume

      @GetMapping(value="/{channelId}/sse", produces="text/event-stream") public org.springframework.http.ResponseEntity<org.springframework.web.servlet.mvc.method.annotation.SseEmitter> resume(@PathVariable String channelId, @RequestParam(name="lastSeq",defaultValue="0") long lastSeq)
      Reconnect endpoint. The client opens a fresh SSE GET on this URL with lastSeq set to the seq of the last event it processed (or 0 for a clean attach). The server replays every event in the channel's ring buffer with seq > lastSeq and then subscribes the emitter to the live feed.

      Use cases:

      • The user pressed F5 or closed/reopened a tab — their original reader is gone, but the server-side run is still going.
      • A second tab observing the same session wants to see the turn live.

      404 when the stream is no longer registered (already finished).