testing channels and goroutines.
[goDBhammer.git] / src / webconnector.go
index eb81cc0..c64e0bd 100644 (file)
@@ -6,27 +6,44 @@ package main
 import (
        "http";
        "io";
-       "./dbibridge";
+       //"./dbibridge";
+       "./benchcontroller";
+       "fmt";
 )
 
+var comin chan int;
+var comout chan int;
+
 // hello world, the web server
 func HelloServer(c *http.Conn, req *http.Request) {
+       comout <- 1;
        io.WriteString(c, "<html><form method=post><input type=\"input\"><input type=\"submit\" name=\"go\" value=\"go\"></html>\n");
+       
+       // fucking go, i just wanna consume the incoming data, but it forces me to do something with it... cunt of a language
+       k := <- comin;
+       fmt.Printf("%d\n", k);
 }
 
 func main() {
 
-       var Dbconn *dbibridge.DBIConnection;
+       //var Dbconn *dbibridge.DBIConnection;
+       
+       //Dbconn = dbibridge.DBICreate();
+       
+       //dbibridge.DBIConnect(Dbconn, "mysql", "localhost", "root", "password", "zm");
+       //dbibridge.ExecSQL(Dbconn, "create table asdf (asdf int)");
+       //dbibridge.DBIDisconnect(Dbconn);
+       
+       comin = make(chan int);
+       comout = make(chan int);
        
-       Dbconn = dbibridge.DBICreate();
+       bc := benchcontroller.CreateController();
+       go benchcontroller.MainLoop(bc, comout, comin);
        
-       dbibridge.DBIConnect(Dbconn, "mysql", "localhost", "root", "password", "zm");
-       dbibridge.ExecSQL(Dbconn, "create table asdf (asdf int)");
-       dbibridge.DBIDisconnect(Dbconn);
-       //http.Handle("/hello", http.HandlerFunc(HelloServer));
-       //err := http.ListenAndServe(":12345", nil);
-       //if err != nil {
-               ////panic("ListenAndServe: ", err.String())
-       //}
+       http.Handle("/hello", http.HandlerFunc(HelloServer));
+       err := http.ListenAndServe(":12345", nil);
+       if err != nil {
+               panic("ListenAndServe: ", err.String())
+       }
 
 }