1 // Copyright 2015 The Gorilla WebSocket Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
12 "github.com/gorilla/websocket"
20 // The websocket.IsUnexpectedCloseError function is useful for identifying
21 // application and protocol errors.
23 // This server application works with a client application running in the
24 // browser. The client application does not explicitly close the websocket. The
25 // only expected close message from the client has the code
26 // websocket.CloseGoingAway. All other other close messages are likely the
27 // result of an application or protocol error and are logged to aid debugging.
28 func ExampleIsUnexpectedCloseError() {
31 messageType, p, err := c.ReadMessage()
33 if websocket.IsUnexpectedCloseError(err, websocket.CloseGoingAway) {
34 log.Printf("error: %v, user-agent: %v", err, req.Header.Get("User-Agent"))
38 processMesage(messageType, p)
42 func processMesage(mt int, p []byte) {}
44 // TestX prevents godoc from showing this entire file in the example. Remove
45 // this function when a second example is added.
46 func TestX(t *testing.T) {}