当前位置:网站首页>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 });边栏推荐
- Why do independent website sellers start to do social media marketing? The original customer conversion rate can be improved so much!
- LeetCode-21合并两个有序链表
- 为什么独立站卖家都开始做社交媒体营销?原来客户转化率能提高这么多!
- 2、《创建您自己的NFT集合并发布一个Web3应用程序来展示它们》启动并运行您的本地环境
- 如何使用物联网低代码平台进行个人设置?
- 创建您自己的NFT集合并发布一个Web3应用程序来展示它们(介绍)
- 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
- What if the reliability coefficient is low? How to calculate the reliability coefficient?
- 毕业总结
- Leetcode-160 intersecting linked list
猜你喜欢

11、用户、组和权限(1)

实现一个Prometheus exporter

透过华为军团看科技之变(六):智慧公路

Vidéos courtes recommandées chaque semaine: méfiez - vous de la confusion entre « phénomène » et « problème »

Lumiprobe non fluorescent alkyne EU (5-ethynyluridine)

Altair HyperWorks 2022 software installation package and installation tutorial

AI 训练速度突破摩尔定律;宋舒然团队获得RSS 2022最佳论文奖

Example explanation: move graph explorer to jupyterlab

LiveData postValue会“丢”数据

What designs are needed in the architecture to build a general monitoring and alarm platform
随机推荐
Lefse analysis
R语言使用epiDisplay包的tableStack函数制作统计汇总表格(基于目标变量分组的描述性统计、假设检验等)、不设置by参数则计算数据框指定数据列范围的基础描述性统计信息
Leetcode-128 longest continuous sequence
Qfile read / write file operation in QT
Facebook聊单,SaleSmartly有妙招!
12 data dimensioning processing methods
ACM MM 2022视频理解挑战赛视频分类赛道冠军AutoX团队技术分享
如何在自有APP内实现小程序实现连麦直播
实例讲解将Graph Explorer搬上JupyterLab
GAMES202作业0-环境搭建过程&解决遇到的问题
3、《创建您自己的NFT集合并发布一个Web3应用程序来展示它们》在本地铸造 NFT
R language ggplot2 visualization: visualize the line graph and add customized Y-axis label information to the line graph using the labels function
Leetcode-160 intersecting linked list
LeetCode-21合并两个有序链表
After studying 11 kinds of real-time chat software, I found that they all have these functions
如何使用物联网低代码平台进行个人设置?
Three.js学习-相机Camera的基本操作(了解向)
华为游戏初始化init失败,返回错误码907135000
Leetcode-83 删除排序链表中重复的元素
Why do independent website sellers start to do social media marketing? The original customer conversion rate can be improved so much!