PlexNotificationsApi class Events and downloads

/:/websockets/notifications and /:/eventsource/notifications — server-push notifications.

Plex exposes the same notification stream over two transports. Use connectWebSocket for full-duplex (no extra polling overhead) or connectEventSource when WebSockets are blocked by an intermediate proxy.

The notification frames carry server state changes: playback progress, library scan progress, transcoder sessions, settings updates, etc. Each frame is exposed as a PlexNotification with a type discriminator; PlexNotification.events and the PlexNotificationEvents.events stream extension decode them into typed PlexEvents.

Both streams are broadcast streams: a frame that arrives while nobody listens is dropped, and cancelling the last subscription closes the connection. Neither transport reconnects: when a stream ends — the server went away, the event source stayed silent — open a new one. PlexClient.close closes both.

Only the event source notices a connection that died without a word (its idleTimeout). The WebSocket cannot: PMS pings the client, which the socket answers unseen, but answers only the first ping a client sends, so there is nothing to time.

Constructors

PlexNotificationsApi(PlexConnection _http)
Construct from a PlexConnection. Typically obtained via PlexClient.notifications.

Properties

hashCode → int
The hash code for this object.
no setterinherited
isEventSourceConnected → bool
True while an EventSource (SSE) stream is open.
no setter
isWebSocketConnected → bool
True while a WebSocket is open.
no setter
malformedFrameCount → int
Frames dropped since this object was created because they could not be read: invalid JSON, a binary WebSocket frame, an event-stream frame past the size cap. The stream stays open and reports no error for them.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
webSocketCloseCode → int?
The close code the server sent when the last WebSocket ended on its own (1005 when its close frame carried none). null while connected, after closeWebSocket, and when the connection dropped without a close frame.
no setter
webSocketCloseReason → String?
The close reason that came with webSocketCloseCode, if any.
no setter

Methods

closeEventSource() → Future<void>
Close the EventSource stream and release resources — also while it is still connecting.
closeWebSocket() → Future<void>
Close the WebSocket and release resources — also while it is still connecting, which makes the pending connectWebSocket throw PlexErrorType.cancelled. Waits a couple of seconds at most for the server to answer the close.
connectEventSource({String? filter, Duration? idleTimeout = const Duration(seconds: 60)}) → Stream<PlexNotification>
GET /:/eventsource/notifications — open a Server-Sent Events stream of notifications. SSE is a one-way (server → client) transport; use this when WebSockets are blocked.
connectWebSocket({String? filter, Duration connectTimeout = const Duration(seconds: 30)}) → Future<Stream<PlexNotification>>
GET /:/websockets/notifications — open a WebSocket and emit every notification as a PlexNotification.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited