Comments (4)
Need to know more about your setup. Are offline / online scenes assigned to Network Manager?
You don't need that if...else if...else if
block...just call NetworkManager.singleton.StopHost();
and Mirror will do the right thing for all cases.
StopDiscovery should already be called automatically as soon as a client connects to a discovered server, so you shouldn't need to call that.
from mirror.
Hi
thanks for the advice . still new to Mirror :)
and i don't use offline / online scenes. i use my own scene switch logic.
my game can play as single or multiplayer.
for the host part. the scene switch flow is same.
Lobby -> Game Scene
-
start Mirror as Host
-
do some stuff before scene swithch
-
call SceneManager.LoadScene(xxx, LoadSceneMode.Single);
-
do some stuff after scene switch
Game Scene -> Lobby
-
stop Mirror
-
do some stuff before scene swithch
-
call SceneManager.LoadScene(xxx, LoadSceneMode.Single);
-
do some stuff after scene switch
this forzen issue is happen in the first step, when i try to stop Mirror.
there are two things maybe relate to this issue
first. currently i don't have the permission to use "com.apple.developer.networking.multicast" (still waiting for permission from Apple)
secondly. HostDiscovery.StartDiscovery() is not been called
-
in my game logic , HostDiscovery.StartDiscovery only called when player try to join the host.
-
and as the "scene switch" part logic it's a common feature in my game. so i call it each time when try to switch scene.
from mirror.
Mirror has overrides in Network Manager for OnServerChangeScene (before) and OnServerSceneChanged (after), as well as OnClientChangeScene (before) and OnClientSceneChanged (after) that would likely suite your needs, and setting offline and online scenes does some work under the hood when you call Stop/Start Server/Host/Client, and network Manager's ServerChangeScene ensures clients all change with the server without message errors.
For Discovery, Server would call AdvertiseServer when started and you'd call StopDiscovery before calling StopHost. Client would call StartDiscovery (StopDiscovery is auto-called for client when it connects).
from mirror.
Hi
thank very much your advice.
I think there should be something wrong with my code.
just make a small suggestion:
Should a warning or error be added to kcp2k or HostDiscovery ? (i still don't know what exactly triggered this problem :( )
this can help users better locate the problem.
It took me a long time to locate this bug.
The main reason is that this bug is very hidden. It only appears on IOS devices. And it can only be triggered after the screen is turned off.
Even if the app is switched repeatedly without turning off the screen, it will still not be triggered.
Just a small suggestion from me.
I wish Mirror all the best!
from mirror.
Related Issues (20)
- KCP Threaded Client Error On Disconnect
- NetworkAnimator: animatorSpeed is never assigned for new clients when joining a game and can cause desync
- KCP - created with cookie HOT 2
- Constructors of custom class/struct do not use syncvar getter/setter for GO/NI/NB.
- Network Rigidbody Reliable not syncing rotation HOT 1
- OnDestroy() isServer returns false on Server Objects, Mirror-89.6.8 HOT 2
- How to implement replicas in MMO? That is, some players enter another scene without affecting other players HOT 3
- Feature request: Predict Rigidbody 2D HOT 1
- Failed to spawn server object, did you forget to add it to the NetworkManager? HOT 1
- Assets\Mirror\Components\PredictedRigidbody\PredictedRigidbody.cs(327,16): error CS1061 HOT 4
- UniEncrypt + Mirror HOT 3
- When crossing assemblies, you may not be able to obtain the Reader/Writer defined by yourself.
- Can Mirror be used to call methods with the [Command] attribute through UI buttons? Why am I getting a NullReferenceException error with the message "Object reference not set to an instance of an object" when I make the call? Does anyone knowledgeable about this issue? HOT 5
- OnValidate logs an error if NetworkIdentity was added after other NetworkBehaviors HOT 3
- Error "InvalidOperationException: Collection was modified; enumeration operation may not execute." in NetworkRoomManager HOT 1
- Mirror can lose a NetworkBehavour object on a client HOT 4
- Conventient way to register multiple processing methods into the same Message HOT 1
- Is there any method to manually sync by network using mirror? HOT 1
- Errors HOT 5
- Bandwidth Abuse HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mirror.