# OnlineBattleManager.kickRoomPlayer(Object option)
以 Promise 风格调用:支持
# 功能描述
踢出指定玩家。仅房主可调用,且对战未开始时可用。
# 参数
# Object option
| 属性 | 类型 | 默认值 | 必填 | 说明 |
| playerId | string | 是 | 被踢玩家的ID | |
| success | function | 否 | 接口调用成功的回调函数 | |
| fail | function | 否 | 接口调用失败的回调函数 | |
| complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
# 注意事项
- 仅房主可调用此方法
- 对战开始后无法踢出玩家
- 被踢的玩家会收到
onPlayerKicked事件通知
# 示例代码
let tapOnlineBattle = tap.getOnlineBattleManager();
// 回调风格
tapOnlineBattle.kickRoomPlayer({
playerId: "player_id_123",
success: (res) => {
console.log('踢出玩家成功');
},
fail: ({errMsg, errno}) => {
console.error('踢出玩家失败:', errMsg);
}
});
// Promise风格
tapOnlineBattle.kickRoomPlayer({
playerId: "player_id_123"
}).then(res => {
console.log('踢出玩家成功');
}).catch(error => {
console.error('踢出玩家失败:', error);
});
