diff --git a/autobahn_test.go b/autobahn_test.go index 5bf0062c5aa094170083e18e3586b38a5822722e..7c735a38dbb4f37c74b89f4a4a79b7f839079bc3 100644 --- a/autobahn_test.go +++ b/autobahn_test.go @@ -36,11 +36,12 @@ var autobahnCases = []string{"*"} func TestAutobahn(t *testing.T) { t.Parallel() - if os.Getenv("AUTOBAHN_TEST") == "" { + if os.Getenv("AUTOBAHN") == "" { t.SkipNow() } - if os.Getenv("AUTOBAHN_FAST") != "" { + if os.Getenv("AUTOBAHN") == "fast" { + // These are the slow tests. excludedAutobahnCases = append(excludedAutobahnCases, "9.*", "13.*", "12.*", ) diff --git a/example_test.go b/example_test.go index 632c4d6e340bf58ebdad6157504982b7f6ed8db8..d44bd537efd40a151f5a8575167895996211b6fc 100644 --- a/example_test.go +++ b/example_test.go @@ -135,6 +135,31 @@ func Example_crossOrigin() { log.Fatal(err) } +func ExampleConn_Ping() { + // Dials a server and pings it 5 times. + + ctx, cancel := context.WithTimeout(context.Background(), time.Minute) + defer cancel() + + c, _, err := websocket.Dial(ctx, "ws://localhost:8080", nil) + if err != nil { + log.Fatal(err) + } + defer c.Close(websocket.StatusInternalError, "the sky is falling") + + // Required to read the Pongs from the server. + ctx = c.CloseRead(ctx) + + for i := 0; i < 5; i++ { + err = c.Ping(ctx) + if err != nil { + log.Fatal(err) + } + } + + c.Close(websocket.StatusNormalClosure, "") +} + // This example demonstrates how to create a WebSocket server // that gracefully exits when sent a signal. //