// startRTMAndDial attemps to connect to the slack websocket. It returns the // full information returned by the "rtm.start" method on the slack API. func (rtm *RTM) startRTMAndDial() (*Info, *websocket.Conn, error) { info, url, err := rtm.StartRTM() if err != nil { return nil, nil, err } conn, err := websocket.Dial(url, "", "http://api.slack.com") if err != nil { return nil, nil, err } return info, conn, err }
// This example demonstrates a trivial client. func ExampleDial() { origin := "http://localhost/" url := "ws://localhost:12345/ws" ws, err := websocket.Dial(url, "", origin) if err != nil { log.Fatal(err) } if _, err := ws.Write([]byte("hello, world!\n")); err != nil { log.Fatal(err) } var msg = make([]byte, 512) var n int if n, err = ws.Read(msg); err != nil { log.Fatal(err) } fmt.Printf("Received: %s.\n", msg[:n]) }