https://github.com/cansik/mqtt-protobuf-example
A simple MQTT and Protobuf example in C#.
https://github.com/cansik/mqtt-protobuf-example
Last synced: 3 months ago
JSON representation
A simple MQTT and Protobuf example in C#.
- Host: GitHub
- URL: https://github.com/cansik/mqtt-protobuf-example
- Owner: cansik
- Created: 2020-07-05T11:15:18.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-07-11T18:34:40.000Z (almost 5 years ago)
- Last Synced: 2025-02-05T06:43:43.872Z (4 months ago)
- Language: C#
- Size: 19.5 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# MQTT with ProtoBuf Example
A simple MQTT and Protobuf example in C#.The idea was to prototype a solution where you are able to connect to a topic with a specific message type:
```csharp
client.Subscribe("hello/world", (sender, topic, message) =>
{
Console.WriteLine($"New Message: {message}");
});client.Subscribe("game/status", (sender, topic, message) =>
{
Console.WriteLine($"New position: {message.Position.X}, {message.Position.Y}");
});
```And of course publish new messages (strings and proto atm):
```csharp
client.Publish("hello/world", "hello world");var status = new Status
{
Enabled = true,
Position = new Vector3()
{
X = 0.5f, Y = 1.5f, Z = 2.4f
}
};
client.Publish("hello/status", status);
```