Esempio n. 1
0
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)
	}
}
Esempio n. 2
0
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)

}
Esempio n. 4
0
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)
}
Esempio n. 5
0
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)
	}
}
Esempio n. 6
0
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)
}
Esempio n. 7
0
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)
}
Esempio n. 8
0
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)
	}
}