package main //go:generate folder2go -handler web webGenerated import ( "log" "net/http" "time" "dev.hexasoftware.com/stdio/wsrpc" "dev.hexasoftware.com/stdio/wsrpc/sample/basic/webGenerated" "github.com/gohxs/webu" ) func MyCliFunc(cli *wsrpc.ClientCtx) { cli.Define("btn1.click", func(param ...interface{}) interface{} { log.Println("Async button clicked") return "The thing clicked in the button" }) for { // do multiple calls select { case <-time.After(10 * time.Second): ret := cli.Call("Hello", wsrpc.DataObj{ "couldbe": "interface", }) log.Println("Response:", ret) } } } func main() { var mux = http.NewServeMux() var rpc = wsrpc.New(MyCliFunc) mux.Handle("/wsrpc/", webu.LogHandler("wsrpc", rpc.ServeHTTP)) mux.HandleFunc("/", webu.LogHandler("/", webGenerated.AssetHandleFunc)) log.Println("Listening :8080") err := http.ListenAndServe(":8081", mux) if err != nil { panic(err) } }