示例#1
0
文件: js.go 项目: platinasystems/weeb
func main() {
	if true {
		wsBaseURL := fmt.Sprintf("ws://%s:%s/ws/", location.Get("hostname"), location.Get("port"))
		ws, err := websocket.Dial(wsBaseURL + "rpc/foo")
		if err != nil {
			log.Fatal("Dial ", err)
			return
		}
		l := &Listener{}
		rpc = weeb.NewRpc(ws, l)
		l.rpc = rpc

		// go HelloRpcClient(rpc)
		go rpc.Serve()
	}

	if false {
		fu()
	}

	jq().Ready(func() {
		screenPixelsPerPoint = findScreenPixelsPerPoint()
		doc.AddEventListeners(document)
		jqBind(jq(":root"))
	})
}
示例#2
0
func handle_ws(ws *websocket.Conn) {
	// Gob based RPC requires binary web socket frames.
	ws.PayloadType = websocket.BinaryFrame
	l := &Listener{}
	r := weeb.NewRpc(ws, l)
	l.rpc = r
	// go HelloRpcClient(r)
	err := r.Serve()
	if err != io.EOF {
		log.Printf("%v", err)
	}
	ws.Close()
}