예제 #1
0
파일: chat.go 프로젝트: xgene/beego
func main() {
	conf := sockjs.NewConfig()
	sockjshandler := sockjs.NewHandler("/chat", chatHandler, conf)
	beego.Router("/", &MainController{})
	beego.RouterHandler("/chat/{<info(.*)>}", sockjshandler)
	beego.Run()
}
예제 #2
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)
	}
}
예제 #3
0
func ExampleNewHandler() {
	// Handle only SockJS requests prefixed with "/echo".
	h := sockjs.NewHandler("/echo", echoHandler, sockjs.NewConfig())
	err := http.ListenAndServe(":8081", h)
	if err != nil {
		fmt.Println(err)
	}
}
예제 #4
0
파일: main.go 프로젝트: piranha/imap2sockjs
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)
	}
}
예제 #5
0
파일: chat.go 프로젝트: jt6211/sockjs-go
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)
	}
}
예제 #6
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)
	}
}
예제 #7
0
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)

}
예제 #8
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)
}
예제 #9
0
파일: main.go 프로젝트: JeremyRubin/go-peri
func main() {
	runtime.GOMAXPROCS(runtime.NumCPU())
	conf := sockjs.NewConfig()
	pool := sockjs.NewSessionPool()
	dev := controllers.NewDevice(pool, 10)
	dev.AddReader("/dev/dp0/s02_roten/count")
	dev.AddReader("/dev/dp0/s04_slider4/updates")
	sockjshandler := sockjs.NewHandler("/socket", dev.SocketHandler, conf)

	dc := controllers.DemandController{}

	beego.Router("/", &dc)
	beego.Router("/test", &controllers.ChatController{})
	beego.RouterHandler("/socket/:info(.*)", sockjshandler)
	beego.Run()
}
예제 #10
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)
}
예제 #11
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)
}
예제 #12
0
파일: chat.go 프로젝트: hngchiming/BTCsport
func init() {
	Users = sockjs.NewSessionPool()
	Conf = sockjs.NewConfig()
	SockjsHandler = sockjs.NewHandler("/chat", ChatHandler, Conf)
}