Skip to main content

Host Management

1 Initialize Host​

Before initializing the host, the host status is UNAVAILABLE.

TJHostHandle tjHostHandle calls createGameHandle to initialize the host, and the host state changes to WAITING.

1.1 Interface Prototype​

// 初始化新宿主
func createGameHandle(view: UIViewController, completion: @escaping (RuntimeGameHandle?, Error?) -> Void))

1.2 Parameter Description​

parameterData TypeRequiredAttribute Description
viewUIViewControllerYesUsed to display host content
completion(RuntimeGameHandle?, Error?) -> VoidYesReturns after successful initializationRuntimeGameHandle instance

1.3 Code Example​

class HostViewController: UIViewController {
var hostHandle: TJHostHandle?
var gameHandle: RuntimeGameHandle?

override func viewDidLoad() {
super.viewDidLoad()

guard let hostHandle else {
dismiss(animated: true)
return
}

hostHandle.createGameHandle(self) { gameHandle, _ in
guard let gameHandle else {
return
}

self.gameHandle = gameHandle
}
}
}

2 Destroy Host​

gameHandle.destroy()