当前位置:网站首页>Summary of cases of players' disconnection and reconnection in Huawei online battle service
Summary of cases of players' disconnection and reconnection in Huawei online battle service
2022-07-01 18:59:00 【Huawei Developer Forum】
Huawei online battle service disconnection and reconnection solution
During the game , Abnormal situations such as network fluctuations often occur , Cause players to drop the line , At this time, if the network is restored, you still want players to join the original game , You can reconnect in the following ways . The allowed reconnection time can be AppGallery Connec The console .
Network exceptions lead to offline scenarios
Network anomalies cause the player client to be disconnected from the online battle server , After a certain period, the server will set the player to be offline , If the game allows players to reconnect to the network after the network is restored in a short time, you need to use the drop and reconnect interface to realize this scenario . Specifically, after the player enters the room , The game passes room.onDisconnect(playerInfo) Method to monitor player dropping events , This method will return player information . Judge if the player drops the line , You need to trigger room.reconnect() Method reconnection , In the process of reconnection, if the network has not been restored, try to reconnect all the time , If the network is restored, deal with it according to the results , You may jump to other game pages if you exceed the allowed reconnection time .
room.onDisconnect((playerInfo) => { // The current player is disconnected if(playerInfo.playerId === room.playerId){ // Reconnection logic reConnect(); }else{ // Other players drop the line }}reConnect() { // Call the reconnect method to reconnect room.reconnect().then(() => { // Reconnection success }).catch((e) => { if (!e.code) { // Network failure, continue to retry this.reConnect(); return; } if (e.code != 0) { // Exit to other pages after the allowed reconnection time } });}Closing the client leads to a drop
Players still want to reconnect to the previous game after closing and reopening the client , At this time, you can judge whether the player is still in a valid room in the return of the initialization interface , If it is still in, it means that it is still within the allowable reconnection time , You can use the join room interface to re join . If you don't want to join the last game at this time , You must call the interface to leave the room before you can re create the room .
client.init().then(() => { // Successful initialization if(client.lastRoomId){ // The current player is still in the previous room , According to the lastRoomId Rejoin the room // If you don't want to join the previous room , Must pass client.leaveRoom Leave the room , Otherwise, an error will be reported when creating a new room or matching a room : The player is already in the room } }).catch(() => { // initialization failed });边栏推荐
- 6款红黄黑榜摄像头评测:谁最安全?谁画质好?从此让你不再踩雷
- ACM mm 2022 video understanding challenge video classification track champion autox team technology sharing
- Lefse analysis
- 2020,最新手机号码手机验证正则表达式,持续更新
- 太爱速M源码搭建,巅峰小店APP溢价寄卖源码分享
- AI training speed breaks Moore's law; Song shuran's team won the RSS 2022 Best Paper Award
- Navicat Premium 15 永久破解和2021版本最新IDEA破解(亲测有效)
- [Chongqing Guangdong education] basic psychology reference materials of Tianjin Normal University
- 每周推荐短视频:警惕“现象”与“问题”相互混淆
- R语言使用epiDisplay包的followup.plot函数可视化多个ID(病例)监测指标的纵向随访图、使用n.of.lines参数指定显示的病例数
猜你喜欢

力扣每日一题-第32天-589.N×树的前序遍历

Leetcode-141 circular linked list

Improve yolov5 with gsconv+slim neck to maximize performance!

Privacy sandbox is finally coming

Lumiprobe biomolecular quantification - qudye Protein Quantification Kit

Lumiprobe lumizol RNA extraction reagent solution

Viewing the whole ecology of Tiktok from a macro perspective

每周推薦短視頻:警惕“現象”與“問題”相互混淆

解决方案:可以ping别人,但是别人不能ping我

Vidéos courtes recommandées chaque semaine: méfiez - vous de la confusion entre « phénomène » et « problème »
随机推荐
R language uses the aggregate function of epidisplay package to divide numerical variables into different subsets based on factor variables, and calculate the summary statistics of each subset
Leetcode-83 delete duplicate elements in the sorting linked list
Three. JS learning - basic operation of camera (learn from)
隐私沙盒终于要来了
12 data dimensioning processing methods
Why do independent website sellers start to do social media marketing? The original customer conversion rate can be improved so much!
How to operate technology related we media well?
2020,最新手机号码手机验证正则表达式,持续更新
如何运营好技术相关的自媒体?
R language uses follow up of epidisplay package Plot function visualizes the longitudinal follow-up map of multiple ID (case) monitoring indicators, and uses n.of The lines parameter specifies the num
Improve yolov5 with gsconv+slim neck to maximize performance!
【快应用】text组件里的文字很多,旁边的div样式会被拉伸如何解决
Docker deploy mysql8.0
Technology implementation and Architecture Practice
Navicat premium 15 permanent cracking and 2021 latest idea cracking (valid for personal testing)
解决方案:可以ping别人,但是别人不能ping我
力扣每日一题-第32天-1232. 缀点成线
Viewing the whole ecology of Tiktok from a macro perspective
Intensive cultivation of channels for joint development Fuxin and Weishi Jiajie held a new product training conference
Must see, time series analysis