ntcore-ts / @ntcore-ts/client / NetworkTablesProtobufTopic
Class: NetworkTablesProtobufTopic<T>
Defined in: pubsub/protobuf-topic.ts:29
Extends
NetworkTablesTopic<Uint8Array<ArrayBufferLike>,T>
Type Parameters
T
T extends object
Constructors
Constructor
new NetworkTablesProtobufTopic<
T>(client,name,options?):NetworkTablesProtobufTopic<T>
Defined in: pubsub/protobuf-topic.ts:55
Creates a new topic. This should only be done after the base NTCore client has been initialized.
Parameters
client
PubSubClient
The client that owns the topic.
name
string
The name of the topic.
options?
The options for the topic.
Returns
NetworkTablesProtobufTopic<T>
Overrides
NetworkTablesTopic.constructor
Properties
_announceParams
protected_announceParams: {id:number;name:string;properties: {cached?:boolean;persistent?:boolean;retained?:boolean; };pubuid?:number;type:string; } |null
Defined in: pubsub/base-topic.ts:23
Inherited from
NetworkTablesTopic._announceParams
_lastChangedTime?
protectedoptional_lastChangedTime?:number
Defined in: pubsub/base-topic.ts:22
Inherited from
NetworkTablesTopic._lastChangedTime
_publisher
protected_publisher:boolean
Defined in: pubsub/topic.ts:25
Inherited from
_publishProperties?
protectedoptional_publishProperties?:object
Defined in: pubsub/topic.ts:27
cached?
optionalcached?:boolean
persistent?
optionalpersistent?:boolean
retained?
optionalretained?:boolean
Inherited from
NetworkTablesTopic._publishProperties
_pubuid?
protectedoptional_pubuid?:number
Defined in: pubsub/topic.ts:26
Inherited from
client
protectedclient:PubSubClient
Defined in: pubsub/base-topic.ts:19
Inherited from
type
readonlytype:"regular"='regular'
Defined in: pubsub/topic.ts:22
Inherited from
Accessors
announced
Get Signature
get announced():
boolean
Defined in: pubsub/base-topic.ts:68
Whether the topic has been announced.
Returns
boolean
Whether the topic has been announced.
Inherited from
id
Get Signature
get id():
number|undefined
Defined in: pubsub/base-topic.ts:44
Gets the ID of the topic.
Returns
number | undefined
The ID of the topic.
Inherited from
lastChangedTime
Get Signature
get lastChangedTime():
number|undefined
Defined in: pubsub/base-topic.ts:60
Gets the server time of the last value change.
Returns
number | undefined
The server time of the last value change.
Inherited from
NetworkTablesTopic.lastChangedTime
name
Get Signature
get name():
string
Defined in: pubsub/base-topic.ts:52
Gets the name of the topic.
Returns
string
The name of the topic.
Inherited from
publisher
Get Signature
get publisher():
boolean
Defined in: pubsub/topic.ts:41
Gets whether the client is the publisher of the topic.
Returns
boolean
Whether the client is the publisher of the topic.
Inherited from
pubuid
Get Signature
get pubuid():
number|undefined
Defined in: pubsub/topic.ts:49
Gets the UID of the publisher.
Returns
number | undefined
The UID of the publisher, or undefined if the client is not the publisher.
Inherited from
subscribers
Get Signature
get subscribers():
Map<number, {callback:CallbackFn<T>;options:SubscribeOptions; }>
Defined in: pubsub/base-topic.ts:76
Gets the subscribers to the topic.
Returns
Map<number, { callback: CallbackFn<T>; options: SubscribeOptions; }>
The subscribers to the topic.
Inherited from
NetworkTablesTopic.subscribers
typeInfo
Get Signature
get typeInfo():
NetworkTablesTypeInfo
Defined in: pubsub/topic.ts:33
Gets the type info for the topic.
Returns
The type info for the topic.
Inherited from
Methods
afterSetWireValue()
protectedafterSetWireValue():void
Defined in: pubsub/topic.ts:110
Called after setWireValue from subclasses that encode before setting. Runs prefix notify and updateServer.
Returns
void
Inherited from
NetworkTablesTopic.afterSetWireValue
announce()
announce(
params):void
Defined in: pubsub/protobuf-topic.ts:267
Marks the topic as announced. This should only be called by the PubSubClient.
Parameters
params
The parameters of the announcement.
id
number = integerSchema
name
string = ...
properties
{ cached?: boolean; persistent?: boolean; retained?: boolean; } = topicPropertiesSchema
properties.cached?
boolean = ...
properties.persistent?
boolean = ...
properties.retained?
boolean = ...
pubuid?
number = ...
type
string = typeStringSchema
Returns
void
Overrides
applyOptions()
applyOptions(
options?):void
Defined in: pubsub/protobuf-topic.ts:106
Applies options to an existing protobuf topic. Used when returning a cached topic from getProtobufTopic so the returned instance has the requested validator, protoFilePath, and defaultValue. A later validator replaces any previous validator because the topic is a singleton.
Parameters
options?
The options to apply.
Returns
void
getValue()
getValue():
T|null
Defined in: pubsub/protobuf-topic.ts:171
Gets the value of the topic.
Returns
T | null
The value of the topic.
Overrides
isPrefix()
isPrefix():
this is NetworkTablesPrefixTopic
Defined in: pubsub/base-topic.ts:36
Returns
this is NetworkTablesPrefixTopic
Inherited from
isRegular()
isRegular(): this is NetworkTablesTopic<string | number | boolean | string[] | Uint8Array<ArrayBufferLike> | boolean[] | number[], string | number | boolean | string[] | Uint8Array<ArrayBufferLike> | boolean[] | number[]>
Defined in: pubsub/base-topic.ts:32
Returns
this is NetworkTablesTopic<string | number | boolean | string[] | Uint8Array<ArrayBufferLike> | boolean[] | number[], string | number | boolean | string[] | Uint8Array<ArrayBufferLike> | boolean[] | number[]>
Inherited from
notifySubscribers()
protectednotifySubscribers():void
Defined in: pubsub/topic.ts:284
Notifies all subscribers of the current value. Protected so derived classes (e.g. NetworkTablesProtobufTopic) can override and pass decoded/transformed values to callbacks.
Returns
void
Inherited from
NetworkTablesTopic.notifySubscribers
publish()
publish(
properties?,id?):Promise<void| {method:"announce";params: {id:number;name:string;properties: {cached?:boolean;persistent?:boolean;retained?:boolean; };pubuid?:number;type:string; }; }>
Defined in: pubsub/protobuf-topic.ts:368
Publishes the topic. If a proto file path was provided, registers the schema first.
Parameters
properties?
The properties to publish the topic with.
cached?
boolean = ...
persistent?
boolean = ...
retained?
boolean = ...
id?
number
The UID of the publisher. You must verify that the ID is not already in use.
Returns
Promise<void | { method: "announce"; params: { id: number; name: string; properties: { cached?: boolean; persistent?: boolean; retained?: boolean; }; pubuid?: number; type: string; }; }>
A promise that resolves when the topic is published.
Overrides
republish()
republish(
client):Promise<void| {method:"announce";params: {id:number;name:string;properties: {cached?:boolean;persistent?:boolean;retained?:boolean; };pubuid?:number;type:string; }; }>
Defined in: pubsub/topic.ts:371
Republishes the topic.
Parameters
client
PubSubClient
The client to republish with.
Returns
Promise<void | { method: "announce"; params: { id: number; name: string; properties: { cached?: boolean; persistent?: boolean; retained?: boolean; }; pubuid?: number; type: string; }; }>
A promise that resolves when the topic is republished.
Inherited from
resendLatestValue()
resendLatestValue():
void
Defined in: pubsub/topic.ts:139
Resends the latest retained value after reconnect.
This is intended to be called after reconnect, once publish frames have been re-sent. This ensures that if the server/robot restarted, it receives the current state.
Returns
void
Inherited from
NetworkTablesTopic.resendLatestValue
resubscribeAll()
resubscribeAll(
client):void
Defined in: pubsub/topic.ts:270
Resubscribes all local subscribers.
Parameters
client
PubSubClient
The client to resubscribe with.
Returns
void
Inherited from
NetworkTablesTopic.resubscribeAll
setProperties()
setProperties(
properties?):Promise<{method:"properties";params: {ack?:boolean;name:string;update: {cached?:boolean;persistent?:boolean;retained?:boolean; }; }; }>
Defined in: pubsub/base-topic.ts:196
Sets the properties of the topic.
Parameters
properties?
Topic properties to update (e.g. { persistent: true, retained: true }).
cached?
boolean = ...
persistent?
boolean = ...
retained?
boolean = ...
Returns
Promise<{ method: "properties"; params: { ack?: boolean; name: string; update: { cached?: boolean; persistent?: boolean; retained?: boolean; }; }; }>
The server's response.
Inherited from
NetworkTablesTopic.setProperties
setValue()
setValue(
value):void
Defined in: pubsub/protobuf-topic.ts:175
Sets the value of the topic. The client must be the publisher of the topic to set the value.
Parameters
value
T
The value to set.
Returns
void
Overrides
setWireValue()
protectedsetWireValue(value):void
Defined in: pubsub/topic.ts:104
Internal: set wire-format value and notify subscribers. Subclasses may call this when encoding decoded values.
Parameters
value
Uint8Array
Returns
void
Inherited from
NetworkTablesTopic.setWireValue
subscribe()
subscribe(
callback,options?):number
Defined in: pubsub/topic.ts:217
Creates a new subscriber.
Parameters
callback
CallbackFn<T>
The callback to call when the topic value changes.
options?
Omit<SubscribeOptions, "prefix"> = {}
The options for the subscriber. immediateNotify is client-side only and is not sent to the NT server. id and save are not part of this public signature.
Returns
number
The UID of the subscriber.
Inherited from
toProtocolSubscribeOptions()
protectedtoProtocolSubscribeOptions(options?):Omit<SubscribeOptions,"prefix"|"immediateNotify">
Defined in: pubsub/base-topic.ts:179
Strips client-only subscribe options (e.g. immediateNotify) before sending to the NT server.
Parameters
options?
Omit<SubscribeOptions, "prefix"> = {}
The subscriber options, possibly including client-only fields.
Returns
Omit<SubscribeOptions, "prefix" | "immediateNotify">
Protocol subscribe options.
Inherited from
NetworkTablesTopic.toProtocolSubscribeOptions
unannounce()
unannounce():
void
Defined in: pubsub/base-topic.ts:108
Marks the topic as unannounced. This should only be called by the PubSubClient.
Returns
void
Inherited from
unpublish()
unpublish():
void
Defined in: pubsub/topic.ts:349
Unpublishes the topic.
Returns
void
Inherited from
unsubscribe()
unsubscribe(
subuid,removeCallback?):void
Defined in: pubsub/base-topic.ts:154
Removes a subscriber
Parameters
subuid
number
The UID of the subscriber.
removeCallback?
boolean = true
Whether to remove the callback. Leave this as true unless you know what you're doing.
Returns
void
Inherited from
NetworkTablesTopic.unsubscribe
unsubscribeAll()
unsubscribeAll():
void
Defined in: pubsub/base-topic.ts:168
Removes all local subscribers.
Returns
void
Inherited from
NetworkTablesTopic.unsubscribeAll
updateValue()
updateValue(
value,lastChangedTime):void
Defined in: pubsub/protobuf-topic.ts:254
Updates the value of the topic. This should only be called by the PubSubClient.
Parameters
value
Uint8Array<ArrayBufferLike>
The value to update.
lastChangedTime
number
The server time of the last value change.
Returns
void