Example #1
0
//-------------------------------------------------------------
// nonsense handlers, to be deleted
// FIXME: change with an appropriate handler
func rootHandler(w http.ResponseWriter, r *http.Request) {
	path := r.URL.Path[1:]
	if path == "" {
		http.ServeFile(w, r, "./static/templates/index.html")
	} else if path == "db" {
		db.Connect()
		fmt.Fprintf(w, db.Test())
	} else {
		fmt.Fprintf(w, "Hi there, you've asked for %s", path)
	}
}
Example #2
0
//-------------------------------------------------------
// main execution block
//-------------------------------------------------------
func main() {
	db.Connect()
	flag.Parse()
	RegisterAllHandlers()
	go h.run()

	// create the dummy users for now
	createDummyUsers()

	http.HandleFunc("/", rootHandler)
	http.HandleFunc("/client", chatHandler)
	http.Handle("/static/", http.FileServer(http.Dir("")))
	http.Handle("/wsclient", websocket.Handler(wsHandlerClient))
	http.Handle("/wsdaemon", websocket.Handler(wsHandlerDaemon))
	if err := http.ListenAndServe(*addr, nil); err != nil {
		log.Fatal("ListenAndServe:", err)
	}
	NewOrg("Anonymous")
}
Example #3
0
func main() {
	db.Connect()
	args := os.Args[1:]

	if len(args) != 3 {
		fmt.Println("Wrong arguments")
		return
	}

	fmt.Println("Starting the simulation.")
	fmt.Println("Organisations:", args[0])
	fmt.Println("Users per org:", args[1])
	fmt.Println("Daemons per org:", args[2])
	fmt.Println()

	// setting up stub db
	norg, err := strconv.Atoi(args[0])
	if err != nil {
		log.Fatal(err)
	}
	nu, err := strconv.Atoi(args[1])
	if err != nil {
		log.Fatal(err)
	}
	nd, err := strconv.Atoi(args[2])
	if err != nil {
		log.Fatal(err)
	}
	setupDBStub(norg, nu, nd)

	// running the simulation
	runSimulation()

	// cleaning up
	cleanTheDB()
}
Example #4
0
// things to do before running all the tests
func Test_before(t *testing.T) {
	db.Connect()
	RegisterAllHandlers()
	TEST = true
}