/// <summary> /// Constructs a DssGuestRoot object. /// </summary> public DssGuestRoot(ISimulator simulatorIface, IDssGuestSetup setupIface) : base(simulatorIface) { this.setupIface = setupIface; this.lobby = null; this.guestSession = new DssGuestSessionSM(this); this.setupStep = new SetupStep(DssMode.GUEST_SIDE); this.connAckTimeoutClock = null; this.setupStepReqTimeoutClock = null; TraceManager.WriteAllTrace("DssGuestRoot created", DssTraceFilters.SETUP_STAGE_INFO); }
/// <summary> /// Connects to an existing DSS-lobby on the network. /// </summary> /// <param name="dssLobby">The information package of the lobby that contains data for the connection.</param> /// <param name="network">The network interface that is used to connect.</param> /// <param name="simulatorIface">Interface of the local simulator implemented by the client module.</param> /// <param name="setupIface">Interface of the setup manager object implemented by the client module.</param> /// <remarks>The caller thread will be blocked while the peer is connected to the DSS.</remarks> public static void ConnectDSS(LobbyInfo dssLobby, INetwork network, ISimulator simulatorIface, IDssGuestSetup setupIface) { if (dssLobby == null) { throw new ArgumentNullException("dssLobby"); } if (network == null) { throw new ArgumentNullException("network"); } if (simulatorIface == null) { throw new ArgumentNullException("simulatorIface"); } if (setupIface == null) { throw new ArgumentNullException("setupIface"); } //throw new Exception("Test exception"); dssActive.WaitOne(); try { DssGuestRoot guestRoot = new DssGuestRoot(simulatorIface, setupIface); GuestEventHandler eventHdl = new GuestEventHandler(guestRoot); guestRoot.EventQueue.RegisterHandler(eventHdl); ILobbyClient client = network.JoinLobby(dssLobby, guestRoot.EventQueue); if (client == null) { throw new DssException("Cannot join to the lobby under the DSS!"); } guestRoot.Lobby = client; guestRoot.EventQueue.EventLoop(); client.Disconnect(); guestRoot.Dispose(); } catch (Exception ex) { TraceManager.WriteExceptionAllTrace(ex, false); } finally { dssActive.Release(); } }