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
| Property | Type | Description |
|---|---|---|
[key: string] | JsonValue |
StartConfig
| Property | Type | Description |
|---|---|---|
url | string | WebSocket endpoint, e.g. ws://localhost:8000/connection/websocket (wss:// for TLS). |
token? | string | Connection JWT. When it expires the SDK asks for a new one with need_token. |
name? | string | Client name sent in the connect command. |
version? | string | Client version sent in the connect command. |
channels | string[] | Channels to subscribe to with default options. |
useProtobuf | boolean | Protobuf instead of JSON protocol. |
readTimeout? | number | Command timeout in milliseconds (SDK default: 5000). |
httpStreamUrl? | string | HTTP-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? | boolean | Ask 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
| Property | Type | Description |
|---|---|---|
channel | string | |
data | string | base64 encoded data (default transport format) |
dataEncoding? | 'base64' | 'rawJson' | |
type? | number | Deprecated. Map publish is not supported by centrifuge-client; a non-zero type is rejected. |
key? | string | Deprecated. Map publish is not supported by centrifuge-client. |
removed? | boolean | Deprecated. Map publish is not supported by centrifuge-client. |
RpcRequest
| Property | Type | Description |
|---|---|---|
method | string | |
data | string | base64 encoded data |
dataEncoding? | 'base64' | 'rawJson' |
PresenceRequest
| Property | Type | Description |
|---|---|---|
channel | string |
PresenceStatsRequest
| Property | Type | Description |
|---|---|---|
channel | string |
HistoryRequest
| Property | Type | Description |
|---|---|---|
channel | string | |
limit? | number | |
since? | string | Deprecated. Ignored. |
reverse? | boolean |
SendRequest
| Property | Type | Description |
|---|---|---|
data | string | base64 encoded data |
dataEncoding? | 'base64' | 'rawJson' |
RefreshRequest
| Property | Type | Description |
|---|---|---|
token | string |
SubRefreshRequest
| Property | Type | Description |
|---|---|---|
channel | string | |
token | string | |
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? | number | Deprecated. Only 0 (token refresh) is supported. |
signature? | string | Deprecated. Ignored. |
KeyedItem
| Property | Type | Description |
|---|---|---|
key | string | |
version | number |
SubscribeOptions
| Property | Type | Description |
|---|---|---|
channel | string | |
token? | string | Subscription JWT (private channel). When it expires the SDK asks for a new one with need_sub_token. |
recoverable? | boolean | Recover missed publications after a reconnect (the channel needs history and recovery on the server). |
joinLeave? | boolean | Receive join / leave events (the channel needs join/leave on the server). |
positioned? | boolean | Positioned subscription: the server checks the stream position and resubscribes on a gap. |
delta? | boolean | Fossil delta compression (the server must allow it for the channel). |
since? | StreamPosition | Resume from a saved position (see SubscribedStatus.streamPosition). |
StreamPosition
| Property | Type | Description |
|---|---|---|
offset | number | |
epoch | string |
SubscribedStatus
Extends ChannelStatus.
| Property | Type | Description |
|---|---|---|
wasRecovering | boolean | The subscription asked to recover (recoverable, or since set). |
recovered | boolean | All missed publications were recovered. |
streamPosition? | StreamPosition | null | Current position in the channel stream (recoverable / positioned channels); save it for since. |
PublicationData
| Property | Type | Description |
|---|---|---|
channel | string | |
data | string | base64 encoded data |
dataEncoding? | 'base64' | 'rawJson' | Always 'base64' on received publications. |
rawJson? | unknown | The data parsed as JSON, when it is valid JSON. |
offset? | number | Offset in the channel stream. |
info? | { client: string user: string connInfo: string chanInfo: string } | |
tags? | Record<string, string> | |
timestamp? | number | Publication time from the server, else arrival time (ms since the epoch). |
ConnectionStatus
| Property | Type | Description |
|---|---|---|
ts | number | Milliseconds since the Unix epoch. |
code? | number | connecting / disconnected: Centrifugo code. |
reason? | string | connecting / disconnected: reason text. |
client? | string | connected: client ID the server assigned. |
ChannelStatus
| Property | Type | Description |
|---|---|---|
channel | string | |
code? | number | subscribing / unsubscribed: Centrifugo code. |
reason? | string | subscribing / unsubscribed: reason text. |
ErrorData
| Property | Type | Description |
|---|---|---|
error | string | |
channel? | string | Set for subscription errors. |
TauriEventWrapper<T>
| Property | Type | Description |
|---|---|---|
event | string | |
payload | T | |
id | number |
RpcResponse
| Property | Type | Description |
|---|---|---|
method | string | |
data | string | base64 encoded data |
timestamp | number |
PresenceResponse
| Property | Type | Description |
|---|---|---|
channel | string | |
clients | string[] | |
timestamp | number |
PresenceStatsResponse
| Property | Type | Description |
|---|---|---|
channel | string | |
numClients | number | |
numUsers | number | |
timestamp | number |
HistoryResponse
| Property | Type | Description |
|---|---|---|
channel | string | |
publications | PublicationData[] | |
timestamp | number |
PingResponse
| Property | Type | Description |
|---|---|---|
timestamp | number |
Type aliases
JsonPrimitive
type JsonPrimitive = string | number | boolean | null
JsonValue
type JsonValue = JsonPrimitive | JsonObject | JsonArray
JsonArray
type JsonArray = JsonValue[]