diff --git a/README.md b/README.md index dbc55c8..0c6d845 100644 --- a/README.md +++ b/README.md @@ -52,3 +52,32 @@ if err != nil { ```go client.Disconnect() ``` + +### publishing a message + +#### bytes + +```go +err := client.Publish(context.WithTimeout(1 * time.Second), "api/v0/main/client1", []byte(0, 1 ,2, 3), mqtt.AtLeastOnce) +if err != nil { + panic(err) +} +``` + +#### string + +```go +err := client.PublishString(context.WithTimeout(1 * time.Second), "api/v0/main/client1", "hello world", mqtt.AtLeastOnce) +if err != nil { + panic(err) +} +``` + +#### json + +```go +err := client.Publish(context.WithTimeout(1 * time.Second), "api/v0/main/client1", []string("hello", "world"), mqtt.AtLeastOnce) +if err != nil { + panic(err) +} +```