Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by leopripos · Sep 11, 2016 at 03:21 AM · networkingunity5

NetworkLobbyManager.OnLobbyStopHost() called when stop Server Only, Is this bug?

I created a class extending UnityEngine.Networking.NetworkLobbyManager bellow.

 public class NetworkLobbyManager : UnityEngine.Networking.NetworkLobbyManager, ISingleton
     {
         /************************************* Start Server Callback ****************************/
         #region Server Collback
  
         /// <summary>
         /// This is called on the host when a host is started.
         /// </summary>
         public override void OnLobbyStartHost()
         {
             Debug.Log("OnLobbyStartHost");
  
             base.OnLobbyStartHost();
         }
  
         /// <summary>
         /// This is called on the host when the host is stopped.
         /// </summary>
         public override void OnLobbyStopHost()
         {
             Debug.Log("OnLobbyStopHost");
             base.OnLobbyStopHost();
         }
  
         /// <summary>
         /// This is called on the server when the server is started - including when a host is started.
         /// </summary>
         public override void OnLobbyStartServer()
         {
             Debug.Log("OnLobbyStartServer");
             base.OnLobbyStartServer();
         }
  
         /// <summary>
         /// This is called on the server when a new client connects to the server.
         /// </summary>
         /// <param name="conn">The new connection.</param>
         public override void OnLobbyServerConnect(NetworkConnection conn)
         {
             Debug.Log("OnLobbyServerConnect connectionId : " + conn.connectionId);
  
             base.OnLobbyServerConnect(conn);
         }
  
         /// <summary>
         /// This is called on the server when a client disconnects.
         /// </summary>
         /// <param name="conn"    The connection that disconnected.></param>
         public override void OnLobbyServerDisconnect(NetworkConnection conn)
         {
             Debug.Log("OnLobbyServerDisconnect connectionId : " + conn.connectionId);
  
             base.OnLobbyServerDisconnect(conn);
         }
  
         /// <summary>
         /// This allows customization of the creation of the GamePlayer object on the server.
         /// By default the gamePlayerPrefab is used to create the game-player, but this function allows that behaviour to be customized.
         /// The object returned from the function will be used to replace the lobby-player on the connection.
         /// </summary>
         /// <param name="conn">The connection the player object is for.</param>
         /// <param name="playerControllerId">The controllerId of the player on the connnection.</param>
         /// <returns>A new GamePlayer object.</returns>
         public override GameObject OnLobbyServerCreateGamePlayer(NetworkConnection conn, short playerControllerId)
         {
             Debug.Log("OnLobbyServerCreateGamePlayer connectionId : " + conn.connectionId + ", playerConntrollerId : " + playerControllerId);
  
             return base.OnLobbyServerCreateGamePlayer(conn, playerControllerId);
         }
  
         /// <summary>
         /// This allows customization of the creation of the lobby-player object on the server.
         /// By default the lobbyPlayerPrefab is used to create the lobby-player, but this function allows that behaviour to be customized.
         /// </summary>
         /// <param name="conn">The connection the player object is for.</param>
         /// <param name="playerControllerId">The controllerId of the player.</param>
         /// <returns>The new lobby-player object.</returns>
         public override GameObject OnLobbyServerCreateLobbyPlayer(NetworkConnection conn, short playerControllerId)
         {
             Debug.Log("OnLobbyServerCreateLobbyPlayer connectionId : " + conn.connectionId + ", playerConntrollerId : " + playerControllerId);
  
             return base.OnLobbyServerCreateLobbyPlayer(conn, playerControllerId);
         }
  
         /// <summary>
         /// This is called on the server when all the players in the lobby are ready.
         /// The default implementation of this function uses ServerChangeScene() to switch to the game player scene.
         /// </summary>
         public override void OnLobbyServerPlayersReady()
         {
             Debug.Log("OnLobbyServerPlayersReady");
  
             base.OnLobbyServerPlayersReady();
         }
  
         /// <summary>
         /// This is called on the server when a player is removed.
         /// </summary>
         /// <param name="conn">The connection the player object that removed.</param>
         /// <param name="playerControllerId">The controllerId of the player that removed.</param>
         public override void OnLobbyServerPlayerRemoved(NetworkConnection conn, short playerControllerId)
         {
             Debug.Log("OnLobbyServerPlayerRemoved connectionId : " + conn.connectionId + ", playerConntrollerId : " + playerControllerId);
  
             base.OnLobbyServerPlayerRemoved(conn, playerControllerId);
         }
  
         /// <summary>
         /// This is called on the server when a networked scene finishes loading.
         /// </summary>
         /// <param name="sceneName">Name of the new scene.</param>
         public override void OnLobbyServerSceneChanged(string sceneName)
         {
             Debug.Log("OnLobbyServerSceneChanged sceneName : " + sceneName);
  
             base.OnLobbyServerSceneChanged(sceneName);
         }
  
         /// <summary>
         /// This is called on the server when it is told that a client has finished switching from the lobby scene to a game player scene.
         /// When switching from the lobby, the lobby-player is replaced with a game-player object.
         /// This callback function gives an opportunity to apply state from the lobby-player to the game-player object.
         /// </summary>
         /// <param name="lobbyPlayer">The lobby player object.</param>
         /// <param name="gamePlayer">The game player object.</param>
         /// <returns>False to not allow this player to replace the lobby player.</returns>
         public override bool OnLobbyServerSceneLoadedForPlayer(GameObject lobbyPlayer, GameObject gamePlayer)
         {
             Debug.Log("OnLobbyServerSceneLoadedForPlayer lobbyPlayer : " + lobbyPlayer.GetInstanceID() + " gamePlayer : " + gamePlayer.GetInstanceID());
  
             return base.OnLobbyServerSceneLoadedForPlayer(lobbyPlayer, gamePlayer);
         }
         #endregion
         /************************************* End Server Callback ****************************/
  
  
  
  
         /************************************* Start Client Callback ****************************/
         #region Client Collback
  
         /// <summary>
         /// This is a hook to allow custom behaviour when the game client enters the lobby.
         /// </summary>
         public override void OnLobbyClientEnter()
         {
             Debug.Log("OnLobbyClientEnter");
  
             base.OnLobbyClientEnter();
         }
  
         /// <summary>
         /// This is a hook to allow custom behaviour when the game client exits the lobby.
         /// </summary>
         public override void OnLobbyClientExit()
         {
             Debug.Log("OnLobbyClientExit");
  
             base.OnLobbyClientExit();
         }
  
         /// <summary>
         /// This is called on the client when it connects to server.
         /// </summary>
         /// <param name="conn">The new connection</param>
         public override void OnLobbyClientConnect(NetworkConnection conn)
         {
             Debug.Log("OnLobbyClientConnect connectionId : " + conn.connectionId);
  
             base.OnLobbyClientConnect(conn);
         }
  
         /// <summary>
         /// This is called on the client when disconnected from a server.
         /// </summary>
         /// <param name="conn">The connection that disconnected.</param>
         public override void OnLobbyClientDisconnect(NetworkConnection conn)
         {
             Debug.Log("OnLobbyClientDisconnect connectionId : " + conn.connectionId);
  
             base.OnLobbyClientDisconnect(conn);
         }
  
         /// <summary>
         /// This is called on the client when a client is started.
         /// </summary>
         /// <param name="lobbyClient">The new network client</param>
         public override void OnLobbyStartClient(NetworkClient lobbyClient)
         {
             Debug.Log("OnLobbyStartClient netowrkClient : " + lobbyClient.connection.connectionId);
  
             base.OnLobbyStartClient(lobbyClient);
         }
  
         /// <summary>
         /// This is called on the client when the client stops.
         /// </summary>
         public override void OnLobbyStopClient()
         {
             Debug.Log("OnLobbyStopClient");
  
             base.OnLobbyStopClient();
         }
  
         /// <summary>
         /// This is called on the client when the client is finished loading a new networked scene.
         /// </summary>
         /// <param name="conn">Connection</param>
         public override void OnLobbyClientSceneChanged(NetworkConnection conn)
         {
             Debug.Log("OnLobbyClientSceneChanged connectionId : " + conn.connectionId);
  
             base.OnLobbyClientSceneChanged(conn);
         }
  
         /// <summary>
         /// Called on the client when adding a player to the lobby fails.
         /// This could be because the lobby is full, or the connection is not allowed to have more players
         /// </summary>
         public override void OnLobbyClientAddPlayerFailed()
         {
             Debug.Log("OnLobbyClientAddPlayerFailed");
  
             base.OnLobbyClientAddPlayerFailed();
         }
  
         #endregion
         /************************************* End Client Callback ****************************/
     }

But, the debug result like this : When Start Server Only, the result :

 OnLobbyStartServer

When Stop the Server Only, the result:

 OnLobbyStopHost
 OnLobbyStopClient
 OnLobbyClientExit

I am using Unity 5.4.0p4. Is this bug?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
â–¼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by leopripos · Sep 11, 2016 at 03:37 AM

I think this is the cause, I found that NetworkManagerHUD implemented like this. So, it make it like a host.

 if (NetworkServer.active || manager.IsClientConnected())
 {
         if (GUI.Button(new Rect(xpos, ypos, 200, 20), "Stop (X)"))
         {
                manager.StopHost();
         }
         ypos += spacing;
 }
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
â–¼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

76 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

lan network discovery 0 Answers

UnityWebRequest does not exist within UnityEngine.Networking 0 Answers

[Networking]How to call a command function from a UI element(a button) 2 Answers

Loading Progress using UNET 2 Answers

Forge Networking Remastered iOS Build Error 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges