Example #1
0
        internal void DisconnectMachine(NetworkMachine machine, NetworkSessionEndReason reason)
        {
            if (!isHost)
            {
                throw new InvalidOperationException();
            }

            if (connectionFromMachine[machine].Status == NetConnectionStatus.Connected)
            {
                connectionFromMachine[machine].Disconnect(reason.ToString());
            }
        }
Example #2
0
        internal void End(NetworkSessionEndReason reason)
        {
            if (IsDisposed || state == NetworkSessionState.Ended)
            {
                return;
            }

            // Note that we do not want to dispose the NetworkSession until the end of this call, as the user
            // might want to do some clean up on SessionEnded. Furthermore, the user might call Dispose() in the
            // callback so the early return above is important. Finally, make sure not to trigger any new events that
            // might arise.
            state = NetworkSessionState.Ended;

            if (isHost)
            {
                // Notify clients gracefully before shutting down
                foreach (var machine in allMachines)
                {
                    if (machine.isLocal)
                    {
                        continue;
                    }
                    DisconnectMachine(machine, NetworkSessionEndReason.HostEndedSession);
                }

                UnregisterWithMasterServer();

                peer.FlushSendQueue();
            }

            InvokeSessionEnded(new NetworkSessionEndedEventArgs(reason));

            TriggerEvents(false);

            RemoveAllMachines();

            peer.Shutdown("Done");

            Session = null;

            IsDisposed = true;
        }
Example #3
0
 public NetworkSessionEndedEventArgs(NetworkSessionEndReason aEndReason)
 {
     endReason = aEndReason;
 }
 public NetworkSessionEndedEventArgs(NetworkSessionEndReason endReason)
 {
     this.endReason = endReason;
 }
 public NetworkSessionEndedEventArgs(
     NetworkSessionEndReason endReason
     )
 {
     EndReason = endReason;
 }
Example #6
0
		public NetworkSessionEndedEventArgs (NetworkSessionEndReason aEndReason)
		{
			endReason = aEndReason;
		}