good morning!!!!

Skip to content
Snippets Groups Projects
Unverified Commit 16952169 authored by Anmol Sethi's avatar Anmol Sethi
Browse files

Add ping example

Closes #227
parent de8e29bd
Branches
Tags
No related merge requests found
......@@ -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.*",
)
......
......@@ -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.
//
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment