SubscribeCB Method
- Last UpdatedApr 08, 2026
- 1 minute read
Subscribes to topic with callbacks.
public void SubscribeCB(
string Topic,
PubSubCallbackMethod CallbackRoutine,
PubSubUpdateFlag UpdateFlag
)
public:
void SubscribeCB(
String^ Topic,
PubSubCallbackMethod^ CallbackRoutine,
PubSubUpdateFlag UpdateFlag
)
Parameters
- Topic
- The topic string to subscribe to.
- CallbackRoutine
- A delegate of type PubSubCallbackMethod for handling received messages.
- UpdateFlag
- Specifies whether or not integrity updates are required.
| Exception | Description |
|---|---|
| PubSubConnection.BadCallException | A previous call to blocking subscribe was made. |
| PubSubConnection.BadTopicException | The topic string is invalid. |
| PubSubConnection.NotInitException | The initialize was not called. |
| PubSubConnection.NoMemException | The memory allocation failed. |
Note: This method is capable of dealing with the serialization required by System.Windows.Forms.Control and all descendants. That is, if the subscriber is a Form Control, then the System.Windows.Forms.Control.Invoke(System.Delegate,System.Object[]) method will be used to execute the callback in a serialized manner. If the Subscriber is not a Forms Control, then the callback is made preemptively.
public void CB (PubSubStatus status, string topic, PubSubBuffer buffer, PubSubHeaderData headerData)
{
// Do something.
}
...
PubSubCallbackMethod CallbackRoutine = new PubSubCallbackMethod(CB);
PubSubConnection PS = new PubSubConnection();
PS.OpenConnection("192.168.10.10", 5051);
PS.SubscribeCB("mySystem.MyTopic", CallbackRoutine, PubSubUpdateFlag.PS_INTEGRITY);
public void CB (PubSubStatus status, string topic, PubSubBuffer buffer, PubSubHeaderData headerData)
{
// Do something.
}
...
PubSubCallbackMethod CallbackRoutine = new PubSubCallbackMethod(CB);
PubSubConnection PS = new PubSubConnection();
PS.OpenConnection("192.168.10.10", 5051);
PS.SubscribeCB("mySystem.MyTopic", CallbackRoutine, PubSubUpdateFlag.PS_INTEGRITY);