Example #1
0
func (a *App) Run() {
	C.app_run(a.app)

}
Example #2
0
func (conn *connection) appStreaming() {
	//------------------------------------------
	if conn.streamingWindowInfo.windowName != "" {
		//------------------------------------------
		wn := C.CString(conn.streamingWindowInfo.windowName)
		conn.appHandle = C.app_create(1024, 0, 0,
			C.int(conn.streamingWindowInfo.outputWidth),
			C.int(conn.streamingWindowInfo.outputHeight),
			wn,
			C.int(conn.streamingWindowInfo.clip_top),
			C.int(conn.streamingWindowInfo.clip_left),
			C.int(conn.streamingWindowInfo.clip_bottom),
			C.int(conn.streamingWindowInfo.clip_right))
		//------------------------------------------

	} else {
		//------------------------------------------
		conn.appHandle = C.app_create(1024, 0, 0,
			C.int(conn.streamingWindowInfo.outputWidth),
			C.int(conn.streamingWindowInfo.outputHeight),
			nil,
			C.int(conn.streamingWindowInfo.clip_top),
			C.int(conn.streamingWindowInfo.clip_left),
			C.int(conn.streamingWindowInfo.clip_bottom),
			C.int(conn.streamingWindowInfo.clip_right))
		//------------------------------------------
	}

	var outData [1024 * 1024]byte
	var outSize uint32

	tick := time.NewTicker(time.Millisecond * 30)
	flag := true
	for {
		select {
		case <-tick.C:
			C.app_run(conn.appHandle, (*C.char)(unsafe.Pointer(&outData[0])), (*C.ulong)(unsafe.Pointer(&outSize)))

			smallArray := make([]byte, outSize)
			copy(smallArray[:], outData[0:outSize])
			err := conn.ws.WriteMessage(2, smallArray)
			if err != nil {
				fmt.Printf("conn.WriteMessage ERROR!!!\n")
				flag = false
				break
			}
			smallArray = nil

		case mouseEvent := <-conn.mouseEvent:
			if mouseEvent.t == 0 {
				C.app_mouseButtonPress(conn.appHandle, C.int(mouseEvent.w), C.int(mouseEvent.h), C.float(mouseEvent.x), C.float(mouseEvent.y))
				fmt.Printf("app_mouseButtonPress\n")
			}
			if mouseEvent.t == 2 {
				C.app_mouseButtonRelease()
			}
			if mouseEvent.t == 1 {
				C.app_mouseMove(conn.appHandle, C.int(mouseEvent.w), C.int(mouseEvent.h), C.float(mouseEvent.x), C.float(mouseEvent.y))
			}

		}
		if !flag {
			break
		}
		runtime.Gosched()
	}
	C.app_destroy(conn.appHandle)
}