API reference

Types

Request, event and result types of tauri-plugin-centrifugo-api, generated from guest-js/index.ts.

Every interface and type alias tauri-plugin-centrifugo-api exports, generated from guest-js/index.ts. Request types are sent to the commands as is (camelCase); event payload types describe what the backend emits.

Interfaces

JsonObject

PropertyTypeDescription
[key: string]JsonValue

StartConfig

PropertyTypeDescription
urlstringWebSocket endpoint, e.g. ws://localhost:8000/connection/websocket (wss:// for TLS).
token?stringConnection JWT. When it expires the SDK asks for a new one with need_token.
name?stringClient name sent in the connect command.
version?stringClient version sent in the connect command.
channelsstring[]Channels to subscribe to with default options.
useProtobufbooleanProtobuf instead of JSON protocol.
readTimeout?numberCommand timeout in milliseconds (SDK default: 5000).
httpStreamUrl?stringHTTP-streaming fallback endpoint, e.g. http://host:8000/connection/http_stream.
headers?Record<string, string>Extra HTTP headers for the WebSocket upgrade / HTTP-stream requests.
requestToken?booleanAsk for the connection token with a need_token event (answer with provideToken) when token is not set. With token set, need_token also comes before the token expires. provideToken('') means "no token".

PublishRequest

PropertyTypeDescription
channelstring
datastringbase64 encoded data (default transport format)
dataEncoding?'base64' | 'rawJson'
type?numberDeprecated. Map publish is not supported by centrifuge-client; a non-zero type is rejected.
key?stringDeprecated. Map publish is not supported by centrifuge-client.
removed?booleanDeprecated. Map publish is not supported by centrifuge-client.

RpcRequest

PropertyTypeDescription
methodstring
datastringbase64 encoded data
dataEncoding?'base64' | 'rawJson'

PresenceRequest

PropertyTypeDescription
channelstring

PresenceStatsRequest

PropertyTypeDescription
channelstring

HistoryRequest

PropertyTypeDescription
channelstring
limit?number
since?stringDeprecated. Ignored.
reverse?boolean

SendRequest

PropertyTypeDescription
datastringbase64 encoded data
dataEncoding?'base64' | 'rawJson'

RefreshRequest

PropertyTypeDescription
tokenstring

SubRefreshRequest

PropertyTypeDescription
channelstring
tokenstring
items?KeyedItem[]Deprecated. track/untrack is not supported by centrifuge-client; rejected.
untrackKeys?string[]Deprecated. track/untrack is not supported by centrifuge-client; rejected.
type?numberDeprecated. Only 0 (token refresh) is supported.
signature?stringDeprecated. Ignored.

KeyedItem

PropertyTypeDescription
keystring
versionnumber

SubscribeOptions

PropertyTypeDescription
channelstring
token?stringSubscription JWT (private channel). When it expires the SDK asks for a new one with need_sub_token.
recoverable?booleanRecover missed publications after a reconnect (the channel needs history and recovery on the server).
joinLeave?booleanReceive join / leave events (the channel needs join/leave on the server).
positioned?booleanPositioned subscription: the server checks the stream position and resubscribes on a gap.
delta?booleanFossil delta compression (the server must allow it for the channel).
since?StreamPositionResume from a saved position (see SubscribedStatus.streamPosition).

StreamPosition

PropertyTypeDescription
offsetnumber
epochstring

SubscribedStatus

Extends ChannelStatus.

PropertyTypeDescription
wasRecoveringbooleanThe subscription asked to recover (recoverable, or since set).
recoveredbooleanAll missed publications were recovered.
streamPosition?StreamPosition | nullCurrent position in the channel stream (recoverable / positioned channels); save it for since.

PublicationData

PropertyTypeDescription
channelstring
datastringbase64 encoded data
dataEncoding?'base64' | 'rawJson'Always 'base64' on received publications.
rawJson?unknownThe data parsed as JSON, when it is valid JSON.
offset?numberOffset in the channel stream.
info?{ client: string user: string connInfo: string chanInfo: string }
tags?Record<string, string>
timestamp?numberPublication time from the server, else arrival time (ms since the epoch).

ConnectionStatus

PropertyTypeDescription
tsnumberMilliseconds since the Unix epoch.
code?numberconnecting / disconnected: Centrifugo code.
reason?stringconnecting / disconnected: reason text.
client?stringconnected: client ID the server assigned.

ChannelStatus

PropertyTypeDescription
channelstring
code?numbersubscribing / unsubscribed: Centrifugo code.
reason?stringsubscribing / unsubscribed: reason text.

ErrorData

PropertyTypeDescription
errorstring
channel?stringSet for subscription errors.

TauriEventWrapper<T>

PropertyTypeDescription
eventstring
payloadT
idnumber

RpcResponse

PropertyTypeDescription
methodstring
datastringbase64 encoded data
timestampnumber

PresenceResponse

PropertyTypeDescription
channelstring
clientsstring[]
timestampnumber

PresenceStatsResponse

PropertyTypeDescription
channelstring
numClientsnumber
numUsersnumber
timestampnumber

HistoryResponse

PropertyTypeDescription
channelstring
publicationsPublicationData[]
timestampnumber

PingResponse

PropertyTypeDescription
timestampnumber

Type aliases

JsonPrimitive

type JsonPrimitive = string | number | boolean | null

JsonValue

type JsonValue = JsonPrimitive | JsonObject | JsonArray

JsonArray

type JsonArray = JsonValue[]