// This example demonstrates a trivial echo server.
func ExampleHandler() {
	http.Handle("/echo", websocket.Handler(EchoServer))
	err := http.ListenAndServe(":12345", nil)
	if err != nil {
		panic("ListenAndServe: " + err.Error())
	}
}
Example #2
0
func main() {
	http.HandleFunc("/duplex.js", func(w http.ResponseWriter, r *http.Request) {
		http.ServeFile(w, r, "../../javascript/dist/duplex.js")
	})
	http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		http.ServeFile(w, r, "../../javascript/demo/index.html")
	})
	go func() {
		fmt.Println("HTTP on 8000...")
		log.Fatal(http.ListenAndServe(":8000", nil))
	}()

	ws := &http.Server{
		Addr:    ":8001",
		Handler: websocket.Handler(WebsocketServer),
	}
	fmt.Println("WS on 8001...")
	log.Fatal(ws.ListenAndServe())
}