Skip to main content

Migrating from misskey_streaming

Streaming is now part of misskey_client. Remove the standalone misskey_streaming dependency after migrating every call site, and use the first misskey_client release that includes issue #30.

Create the integrated client

// Before
final streaming = MisskeyStreaming.create(
origin: Uri.parse('https://misskey.example.com'),
token: token,
enableAutoReconnect: true,
debugLog: true,
);

// After
final client = MisskeyClient(
config: MisskeyClientConfig(
baseUrl: Uri.parse('https://misskey.example.com'),
enableLog: true,
),
tokenProvider: () => token,
streamingConfig: MisskeyStreamingConfig(enableAutoReconnect: true),
);
await client.streaming.connect();

MisskeyStreaming.fromClient() is no longer needed. The integrated connection shares the URL, token provider, logger, and log setting of MisskeyClient.

Wrap an existing void oldLogger(String level, String message) callback with FunctionLogger(oldLogger), pass it as the client's logger, and set MisskeyClientConfig.enableLog to true.

Replace subscriptions and capture calls

// Before
final handle = await streaming.subscribeChannelStream(
channel: 'homeTimeline',
params: {'withRenotes': true},
);
handle.stream.listen((message) => print(message.body));
streaming.captureNote(handle.id, noteId);

// After
final home = await client.streaming.subscribe(
const MisskeyStreamingChannel.homeTimeline(withRenotes: true),
);
home.messages.listen((message) => print(message.body));
home.captureNote(noteId);

Use subscribeRaw(channel: ..., params: ..., id: ...) for a fork-specific channel. unsubscribe() is now asynchronous, so await it.

Standalone APIIntegrated API
MisskeySubscriptionHandle.streamHandle messages, events, notes, or notifications
MisskeyStreamingClient.messagesFor(id)The matching handle's messages
MisskeyStreamingClient.messagesclient.streaming.messages (outer envelopes)
captureNote(handle.id, noteId)handle.captureNote(noteId)
uncaptureNote(handle.id, noteId)handle.uncaptureNote(noteId)
MisskeyMessageMisskeyStreamingMessage
Manual typed decodingMisskeyStreamingEvent and MisskeyUnknownEvent

Map lifecycle and configuration

Standalone APIIntegrated API
status streamstateChanges plus the current state
isConnectedstate == MisskeyStreamingConnectionState.connected
Reconnection fieldsThe same fields on MisskeyStreamingConfig
MisskeyStreamingConfig.subscriptionTimeout
originMisskeyClientConfig.baseUrl
token / tokenProviderMisskeyClient's tokenProvider argument
debugLog / logger callbackClient enableLog: true / logger: FunctionLogger(oldLogger)
pingIntervalRemoved; no public application-level ping timer
customHeaders / protocolsNo public integrated setting
connectorInternal test injection only
exceptionMapperTyped Streaming exceptions and the errors stream

Use disconnect() when the connection will be reused. Use terminal dispose(), or dispose the owning MisskeyClient, when finished. MisskeyClient.dispose() is idempotent and closes both initialized Streaming resources and the HTTP transport.

sendToChannel() has no integrated public replacement. Open an issue if an upstream or fork protocol requires outbound channel events.

For complete examples and event details, see the Streaming API guide. The root repository also contains the full migration reference.