Coder Social home page Coder Social logo

Comments (4)

MrGadget1024 avatar MrGadget1024 commented on May 28, 2024

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.

Tunied avatar Tunied commented on May 28, 2024

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.

MrGadget1024 avatar MrGadget1024 commented on May 28, 2024

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.

Tunied avatar Tunied commented on May 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.