/// <summary> /// Create a new ConnectionID for a user. /// </summary> /// <param name="ipEndPoint"></param> public ConnectionID(IPEndPoint ipEndPoint) { networkStateMachine = new NetworkStateMachine(NetworkStateMachine.NetworkState.CONNECTIONCONNECTED); InitStateMachine(); MissedSyncs = 0; ID = currentID++; IPEndPoint = ipEndPoint; return; }
protected NetworkWorker networkWorker; // The worker thread used to send and receive data #endregion Fields #region Constructors /// <summary> /// Create a new NetworkBase. /// </summary> /// <param name="startingState">The state to start the network state machine in.</param> protected NetworkBase(NetworkStateMachine.NetworkState startingState) { networkStateMachine = new NetworkStateMachine(startingState); RegisterStateMachineTransitions(); continueRunning = true; gameDataUpdater = null; // Set this to null initially networkThread = new Thread(NetworkMain); networkThread.IsBackground = true; return; }
/// <summary> /// Change the state of this connection ID through the internal network state machine. /// </summary> /// <param name="transitionEvent">The transition event to run to apply to the internal network state machine.</param> public void ChangeState(NetworkStateMachine.TransitionEvent transitionEvent) { lock (this) { networkStateMachine.DoTransition(transitionEvent, null); } return; }