void Awake() { Started.AddListener(OnRoomStartServer); Stopped.AddListener(OnRoomStopServer); Connected.AddListener(OnRoomServerConnected); Authenticated.AddListener(OnRoomServerAuthenticated); Disconnected.AddListener(OnRoomServerDisConnected); OnStartHost.AddListener(OnRoomStartHost); OnStopHost.AddListener(OnRoomStopHost); }
//readonly NetworkTime _time = new NetworkTime(); /// <summary> /// Time kept in this server /// </summary> //public NetworkTime Time //{ // get { return _time; } //} /// <summary> /// This shuts down the server and disconnects all clients. /// </summary> public void Disconnect() { if (LocalClient != null) { OnStopHost?.Invoke(); LocalClient.Disconnect(); } // make a copy, during disconnect, it is possible that connections // are modified, so it throws // System.InvalidOperationException : Collection was modified; enumeration operation may not execute. var playersCopy = new HashSet <INetworkPlayer>(Players); foreach (INetworkPlayer player in playersCopy) { player.Connection?.Disconnect(); } if (Transport != null) { Transport.Disconnect(); } }