func main() { turnpike.Debug() s := turnpike.NewBasicWebsocketServer("turnpike.chat.realm") http.Handle("/", http.FileServer(http.Dir("."))) http.Handle("/ws", s) log.Println("turnpike server starting on port 8000") log.Println("Hint: start clicking on the web page(s) you open to localhost:8000") log.Fatal(http.ListenAndServe(":8000", nil)) }
func main() { turnpike.Debug() s := turnpike.NewBasicWebsocketServer("turnpike.examples") server := &http.Server{ Handler: s, Addr: ":8000", } log.Println("turnpike server starting on port 8000") log.Fatal(server.ListenAndServe()) }
func main() { turnpike.Debug() s := turnpike.NewBasicWebsocketServer("turnpike.examples") server := &http.Server{ Handler: s, Addr: ":8000", } client, _ = s.GetLocalClient("turnpike.examples", nil) if err := client.BasicRegister("alarm.set", alarmSet); err != nil { panic(err) } log.Println("turnpike server starting on port 8000") log.Fatal(server.ListenAndServe()) }
func main() { flag.Parse() if debug { turnpike.Debug() } s := turnpike.NewBasicWebsocketServer(realm) shutdown := make(chan os.Signal, 1) signal.Notify(shutdown, os.Interrupt) go func() { <-shutdown s.Close() log.Println("shutting down server...") time.Sleep(time.Second) os.Exit(1) }() server := &http.Server{ Handler: s, Addr: ":8000", } log.Printf("turnpike server starting on port %d...", port) log.Fatal(server.ListenAndServe()) }