Reserved topics
There is a few reserved topics (or protocol topics) inside of XSockets. These topics are used for things like:
- Lifetime events (open, close)
- Errors
- Pub/Sub
- Hearbeats, ping/pong
- Storage
Below you will find the table for these reserved topics.
Topic | Meaning | Description |
---|---|---|
0 | Authentication Failed | The IAuthenticationPipeline return false. This means that no anonymous connections are allowed and the client will be disconnected |
1 | Init | Initialize a controller, this will create a open a new controller if it is not already in use by the client. If there is no init message send by the client it will be initialized on first usage |
2 | Open | The server send a message about the controller being opened. The message will also contains PI (PersistenId) and CI (ControllerId) |
3 | Close | The client can send this topic to close/dispose a controller. The server will respond with the same topic to let the client know that the controller was closed. This has nothing to do with the actual socket, it is only the controller instances. |
4 | Error | The topic when the server reports and error |
5 | Subscribe | The topic for creating a subscription when using the pub/sub communication pattern |
6 | Unsubscribe | The topic for removing a subscription when using the pub/sub communication pattern |
7 | Ping | Topic for ping, when the client sends a ping the server will respond with a pong. When the server send a ping, the client should respond with a pong. |
8 | Pong | Topic for pong, when the client sends a ping the server will respond with a pong. When the server send a ping, the client should respond with a pong. |
9 | MsgAck | Used for acknowledge of messages with QoS > 0 |
10 | MsgRel | Reserved for future implementation of QoS > 1 |
11 | MsgRec | Reserved for future implementation of QoS > 1 |
12 | MsgComp | Reserved for future implementation of QoS > 1 |
13 | SubAck | Reserved for future usage |
14 | UnsubAck | Reserved for future usage |
s1 | StorageSave | Save the key/value passed in into the storage module for the current PersistenId. |
s2 | StorageGet | Get the key/value from the storage module that matches the key sent in for the current PersistenId. |
s3 | StorageRemove | Remove the key/value from the storage module that macthes the key sent in for the current PersistenId. |
s4 | StorageClear | Clear the storge for the current PersistenId. |
Sample
A simple sample to show this in action from putty. Both lifetime events and the storage module are areas that will be described in depth further on. This is just a small sample/introduction in combination with the reserved topics.
Init/Open
By sending in the topic for init
on a controller
the server will create an instance and report back with the topic for open
.
Close
After opening a controller we can dispose of it by sending a close topic.
ReOpen
If we communicate over the controller after it's closed it will reopen and get a new ControllerId. The PersistentId will remain the same.
Save to storage
We open the controller named my and save a key/value pair... In this case key = foo, value = bar
At the first red dot we open the controller, at the second one we set the key=foo to the value=bar.
Get from storage
We can now read the value back from the storage.
At the first red dot we save the value=bar to the key=foo. At the second one we read the key=foo, and get back the object stored.
Storage remove/clear
Will be covered in the section about the storage module.