Example #1
0
func setup_deje_env(t *testing.T) (string, string, func(), *deje.SimpleClient, deje.Client) {
	tp := turnpike.NewServer()
	router := httptest.NewServer(tp.Handler)
	deje_url := strings.Replace(router.URL, "http", "deje", 1) + "/"
	router_url, topic, err := deje.GetRouterAndTopic(deje_url)
	if err != nil {
		t.Fatal(err)
	}
	closer := func() {
		router.CloseClientConnections()
		router.Close()
	}

	clever, err := deje.Open(deje_url, nil, nil)
	if err != nil {
		t.Fatal(err)
	}

	dumb := deje.NewClient(topic)
	err = dumb.Connect(router_url)
	if err != nil {
		t.Fatal(err)
	}
	<-time.After(50 * time.Millisecond)

	return router_url, topic, closer, clever, dumb
}
Example #2
0
func setupRouter() (url string, closer func()) {
	websocket_server := httptest.NewServer(turnpike.NewServer().Handler)
	closer = func() {
		websocket_server.CloseClientConnections()
		websocket_server.Close()
	}
	url = strings.Replace(websocket_server.URL, "http", "deje", 1) + "/root"
	return
}
Example #3
0
func ExampleServer_NewServer() {
	s := turnpike.NewServer()

	http.Handle("/ws", s.Handler)
	err := http.ListenAndServe(":8080", nil)
	if err != nil {
		panic("ListenAndServe: " + err.Error())
	}
}
Example #4
0
func main() {
	s := turnpike.NewServer()
	s.RegisterRPC("rpc:test", handleTest)

	http.Handle("/ws", s.Handler)
	err := http.ListenAndServe(":8080", nil)
	if err != nil {
		panic("ListenAndServe: " + err.Error())
	}
}
Example #5
0
func main() {
	s := turnpike.NewServer()
	http.Handle("/ws", s.Handler)
	http.Handle("/", http.FileServer(http.Dir("web")))

	fmt.Println("Listening on port 8080")
	if err := http.ListenAndServe(":8080", nil); err != nil {
		log.Fatal("ListenAndServe:", err)
	}
}
Example #6
0
func main() {
	flag.Parse()
	s := turnpike.NewServer()
	ws := websocket.Handler(s.HandleWebsocket)
	http.Handle("/ws", ws)
	http.Handle("/", http.FileServer(http.Dir("web")))

	fmt.Println("Listening on port " + *port)
	if err := http.ListenAndServe(":"+*port, nil); err != nil {
		log.Fatal("Speck:", err)
	}
}