示例#1
0
func rdpconnect(sendq chan []byte, recvq chan []byte, settings *rdpConnectionSettings) {
	var instance *C.freerdp

	fmt.Println("RDP Connecting...")

	instance = C.freerdp_new()

	C.bindCallbacks(instance)
	instance.context_size = C.size_t(unsafe.Sizeof(rdpContext{}))
	C.freerdp_context_new(instance)

	var context *rdpContext
	context = (*rdpContext)(unsafe.Pointer(instance.context))
	context.sendq = sendq
	context.recvq = recvq
	context.settings = settings

	C.freerdp_connect(instance)

	mainEventLoop := true

	for mainEventLoop {
		select {
		case <-recvq:
			fmt.Println("Disconnecting (websocket error)")
			mainEventLoop = false
		default:
			e := int(C.freerdp_error_info(instance))
			if e != 0 {
				switch e {
				case 1:
				case 2:
				case 7:
				case 9:
					// Manual disconnections and such
					fmt.Println("Disconnecting (manual)")
					mainEventLoop = false
					break
				case 5:
					// Another user connected
					break
				default:
					// Unknown error?
					break
				}
			}
			if int(C.freerdp_shall_disconnect(instance)) != 0 {
				fmt.Println("Disconnecting (RDC said so)")
				mainEventLoop = false
			}
			if mainEventLoop {
				C.freerdp_check_fds(instance)
			}
			C.usleep(1000)
		}
	}
	C.freerdp_free(instance)
}
示例#2
0
文件: rdp.go 项目: gonewbee/myTest
func test() {
	instance := C.freerdp_new()
	log.Printf("instance address:%p", instance)
	log.Printf("instance:%v", instance)
	log.Println(instance.PreConnect)
}