func main() { conf := sockjs.NewConfig() sockjshandler := sockjs.NewHandler("/chat", chatHandler, conf) beego.Router("/", &MainController{}) beego.RouterHandler("/chat/{<info(.*)>}", sockjshandler) beego.Run() }
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) } }
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() }
func init() { Users = sockjs.NewSessionPool() Conf = sockjs.NewConfig() SockjsHandler = sockjs.NewHandler("/chat", ChatHandler, Conf) }