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
| parameter | Data Type | Required | Attribute Description |
|---|---|---|---|
view | UIViewController | Yes | Used to display host content |
completion | (RuntimeGameHandle?, Error?) -> Void | Yes | Returns 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()