subscribe

command
v1.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 26, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

README

websocket subscription

output1

run subscription

By connecting to specific topic, the connection on websocket will wait until a message arrives

url := "ws://localhost/ws/sub/test"
conn, _, _ := websocket.DefaultDialer.Dial(url, nil)
defer conn.Close()

for {
  _, msg, err := c.ReadMessage()
  if err != nil {
    log.Fatal(err)
    return
  }
  fmt.Printf("recv: %s\n", msg, t)
}

publish topic

Use the POST method for any topic name (test this time) and set the value.

$ curl -X POST http://localhost:8080/pub/test -d 'hello'

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL