Documentation ¶
Overview ¶
Example (EstablishConnection) ¶
ExampleEstablishConnection demonstrates how to use this library to talk STOMP over a websocket connection
// timeout if the connection isn't established after ten seconds ctx, cancel := context.WithTimeout(context.Background(), time.Second*10) // connect to websocket conn, err := wsstomp.Connect(ctx, "wss://test.com/ws", nil) cancel() if err != nil { log.Printf("error during WS connect: %v", err) return } // init STOMP connection using the websocket connections stompConn, err := stomp.Connect(conn) if err != nil { conn.Close() log.Printf("error during STOMP connect: %v", err) return } defer func() { err = stompConn.Disconnect() if err != nil { log.Printf("error during STOMP disconnect: %v", err) } }() // send a message err = stompConn.Send("/queue/a", "text/plain", []byte("hello world!")) if err != nil { log.Println(err) return }
Output:
Index ¶
Examples ¶
Constants ¶
View Source
const ( NullByte = 0x00 LineFeedByte = 0x0a )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type WebsocketSTOMP ¶
type WebsocketSTOMP struct {
// contains filtered or unexported fields
}
func Connect ¶
func Connect(ctx context.Context, url string, options *websocket.DialOptions) (*WebsocketSTOMP, error)
Establish a websocket connection with the provided URL. The context parameter will only be used for the connection handshake, and not for the full lifetime of the connection.
func (*WebsocketSTOMP) Close ¶
func (w *WebsocketSTOMP) Close() error
Click to show internal directories.
Click to hide internal directories.