voicePlaying 回包对齐原项目:从 "Response from voicePlaying" 改为 "voicePlaying"
契约影响:H5-Native-Contract.md §3.1 [6] voicePlaying responseCallback。 新外壳此前按其它 handler 的 "Response from XXX" 模式套写,与原项目 gameController.m:573 / NewRootVC.m:451 不一致(原项目这里就是 handler 名本身 作回包,是历史包袱)。虽然 H5 通常不校验 cb 内容,但字面保持一致是契约硬约束。
This commit is contained in:
@@ -24,11 +24,14 @@ public enum VoicePlayingHandler {
|
||||
public static func register(on bridge: any BridgeProtocol) {
|
||||
// 【6】voicePlaying
|
||||
// 入参 int 1=允许 / 其它=静默
|
||||
// cb:"Response from voicePlaying"
|
||||
// cb:"voicePlaying"(字面与 handler 名相同,不是 "Response from voicePlaying")
|
||||
bridge.register("voicePlaying") { data, callback in
|
||||
let on = (data?.asInt ?? 0) == 1
|
||||
Task { await VoiceCenter.shared.setEnabled(on) }
|
||||
callback?(.string("Response from voicePlaying"))
|
||||
// 注意回包字面是 "voicePlaying",不是 "Response from voicePlaying"。
|
||||
// 与其它 handler 的 "Response from XXX" 模式不一致是原项目历史包袱
|
||||
// (daoqi/msext gameController.m:573、NewRootVC.m:451 都是 responseCallback(@"voicePlaying"))
|
||||
callback?(.string("voicePlaying"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user