No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 

27 líneas
583 B

  1. // Copyright 2012 The Go 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.
  4. package websocket_test
  5. import (
  6. "io"
  7. "net/http"
  8. "golang.org/x/net/websocket"
  9. )
  10. // Echo the data received on the WebSocket.
  11. func EchoServer(ws *websocket.Conn) {
  12. io.Copy(ws, ws)
  13. }
  14. // This example demonstrates a trivial echo server.
  15. func ExampleHandler() {
  16. http.Handle("/echo", websocket.Handler(EchoServer))
  17. err := http.ListenAndServe(":12345", nil)
  18. if err != nil {
  19. panic("ListenAndServe: " + err.Error())
  20. }
  21. }