func main() { static := http.FileServer(http.Dir("static/")) s := sockjs.NewServeMux(static) s.Handle("/api", connHandler, sockjs.NewConfig()) println("starting on 7171...") err := http.ListenAndServe(":7171", s) if err != nil { log.Fatal(err) } }
func main() { mux := sockjs.NewServeMux(http.DefaultServeMux) conf := sockjs.NewConfig() http.Handle("/static", http.FileServer(http.Dir("./static"))) http.HandleFunc("/", indexHandler) mux.Handle("/chat", chatHandler, conf) err := http.ListenAndServe(":8081", mux) if err != nil { fmt.Println(err) } }
func _startWebsocketServer() { wsCfg := &wsConfig{} framework.Config.ReadInto("websocket", &wsCfg) log.Println("Starting websocket server on port", wsCfg.Port) server := sockjs.NewServeMux(http.DefaultServeMux) conf := sockjs.NewConfig() server.Handle("/ws", wssockjs.HandleSockjsSession, conf) http.ListenAndServe(":"+wsCfg.Port, server) }
func main() { config := readConfig() http.Handle("/", http.FileServer(http.Dir(dirname()+"/"+staticDir+"/"))) sockjsMux := sockjs.NewServeMux(http.DefaultServeMux) sockjsConf := sockjs.NewConfig() sockjsMux.Handle("/data", dataHandler, sockjsConf) geolocEvents := make(chan hpfeeds.Message) go hpfeedsConnect(config, geolocEvents) go broadcast(geolocEvents) log.Printf("Binding Honeymap webserver to %s...", bind) err := http.ListenAndServe(bind, sockjsMux) checkFatalError(err) }
func Example() { // Handlers for two echo servers and a file server. conf := sockjs.NewConfig() dwsconf := sockjs.NewConfig() dwsconf.Websocket = false mux := sockjs.NewServeMux(http.DefaultServeMux) mux.Handle("/echo", echoHandler, conf) mux.Handle("/disabled_websocket_echo", echoHandler, dwsconf) http.Handle("/static", http.FileServer(http.Dir("./static"))) err := http.ListenAndServe(":8081", mux) if err != nil { fmt.Println(err) } }
func main() { http.Handle("/", http.FileServer(http.Dir("../../client/"))) sockjsMux := sockjs.NewServeMux(http.DefaultServeMux) sockjsConf := sockjs.NewConfig() sockjsMux.Handle("/data", dataHandler, sockjsConf) go func() { for { lat := rand.Float32()*180 - 90 lng := rand.Float32()*360 - 180 sockjsClients.Broadcast([]byte(fmt.Sprintf("{ \"latitude\": %f, \"longitude\": %f }", lat, lng))) time.Sleep(100 * time.Millisecond) } }() log.Printf("Binding Honeymap webserver to %s...", bind) http.ListenAndServe(bind, sockjsMux) }
func main() { http.Handle("/", http.FileServer(http.Dir(dirname()+"/"+staticDir+"/"))) sockjsMux := sockjs.NewServeMux(http.DefaultServeMux) sockjsConf := sockjs.NewConfig() sockjsMux.Handle("/data", dataHandler, sockjsConf) go events_listner() go func() { for { var msg = <-message //s:=fmt.Sprintf("{\"latitude\": 32.0617, \"type\": \"blacklist\", \"longitude\": 118.7778,\"countrycode\":\"PT\", \"city\":\"Lisboa\"}") sockjsClients.Broadcast([]byte(msg)) } }() log.Printf("Binding Honeymap webserver to %s...", bind) err := http.ListenAndServe(bind, sockjsMux) checkFatalError(err) }
func main() { mux := sockjs.NewServeMux(http.DefaultServeMux) conf := sockjs.NewConfig() conf.ResponseLimit = 4096 dwsconf := sockjs.NewConfig() dwsconf.Websocket = false cookieconf := sockjs.NewConfig() cookieconf.Jsessionid = true http.Handle("/static", http.FileServer(http.Dir("./static"))) mux.Handle("/echo", echoHandler, conf) mux.Handle("/disabled_websocket_echo", echoHandler, dwsconf) mux.Handle("/cookie_needed_echo", echoHandler, cookieconf) mux.Handle("/close", func(s sockjs.Session) { s.End() }, conf) err := http.ListenAndServe(":8081", mux) if err != nil { fmt.Println(err) } }