From cffb4344d0953731d04f30a3209a436364164edd Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sat, 11 May 2019 20:14:37 -0700 Subject: [PATCH] s/c/conn/ Signed-off-by: Jeff Carr --- example-gorilla/Makefile | 5 +++++ example-gorilla/client.go | 12 ++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 example-gorilla/Makefile diff --git a/example-gorilla/Makefile b/example-gorilla/Makefile new file mode 100644 index 0000000..04bebc2 --- /dev/null +++ b/example-gorilla/Makefile @@ -0,0 +1,5 @@ +server: + go run server.go + +client: + go run client.go diff --git a/example-gorilla/client.go b/example-gorilla/client.go index 16a85aa..a3cd3d0 100644 --- a/example-gorilla/client.go +++ b/example-gorilla/client.go @@ -50,16 +50,16 @@ func main() { u := url.URL{Scheme: "ws", Host: *addr, Path: "/echo"} log.Printf("connecting to %s", u.String()) - c, _, err := websocket.DefaultDialer.Dial(u.String(), nil) + conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil) if err != nil { log.Fatal("dial:", err) } - defer c.Close() + defer conn.Close() done := make(chan struct{}) // handle inbound messages on the channel - go readConn(done, c) + go readConn(done, conn) ticker := time.NewTicker(time.Second) defer ticker.Stop() @@ -69,7 +69,7 @@ func main() { case <-done: return case t := <-ticker.C: - err := c.WriteMessage(websocket.TextMessage, []byte(t.String())) + err := conn.WriteMessage(websocket.TextMessage, []byte(t.String())) if err != nil { log.Println("write:", err) return @@ -78,7 +78,7 @@ func main() { msg := pb.CreateSampleEvent() msg.Name = "test echo over gorilla websocket" data, _ := proto.Marshal(msg) - err2 := c.WriteMessage(websocket.BinaryMessage, data) + err2 := conn.WriteMessage(websocket.BinaryMessage, data) if err2 != nil { log.Println("write:", err2) return @@ -88,7 +88,7 @@ func main() { // Cleanly close the connection by sending a close message and then // waiting (with timeout) for the server to close the connection. - err := c.WriteMessage(websocket.CloseMessage, websocket.FormatCloseMessage(websocket.CloseNormalClosure, "")) + err := conn.WriteMessage(websocket.CloseMessage, websocket.FormatCloseMessage(websocket.CloseNormalClosure, "")) if err != nil { log.Println("write close:", err) return