Beispiel #1
0
 /// <summary>
 /// Internal function to reset the SetupStep objects of all channels.
 /// </summary>
 private void ResetSteps()
 {
     for (int i = 0; i < this.sessions.Length; i++)
     {
         SetupStep currStep = this.hostRoot.GetStep(i);
         if (currStep.State == SetupStepState.READY || currStep.State == SetupStepState.ERROR)
         {
             currStep.Reset();
         }
     }
 }
Beispiel #2
0
        /// <summary>
        /// Sends the setup step answer to the host.
        /// </summary>
        private void ContinueSetup()
        {
            /// Send the answer packages.
            SetupStep currStep = this.guestRoot.Step;

            RCPackage[] packagesToSend = currStep.CreateAnswer(this.channelProxy.OutgoingPackages != null ?
                                                               this.channelProxy.OutgoingPackages :
                                                               new RCPackage[0] {
            });
            currStep.Reset();
            foreach (RCPackage pckg in packagesToSend)
            {
                this.guestRoot.Lobby.SendControlPackage(pckg);
            }

            /// Trigger the session state machine.
            this.SendingSetupStepAW_WaitingSetupStepRQ.Fire();
        }
Beispiel #3
0
        /// <summary>
        /// Sends the setup step requests to the guests, perform the tasks initiated by the client module and
        /// send the SMC to waiting state.
        /// </summary>
        private void ContinueSetup()
        {
            this.SetupStepTimerInactive_Running.Fire();
            this.SendingSetupStepRQs_WaitingSetupStepAWs.Fire();

            /// First handle the channels where drop happened.
            for (int i = 0; i < this.channelProxies.Length; i++)
            {
                if (this.channelProxies[i].TaskToPerform == DssChannelTask.DROP_AND_OPEN ||
                    this.channelProxies[i].TaskToPerform == DssChannelTask.DROP_AND_CLOSE)
                {
                    /// Drop guest and close channel if necessary.
                    this.channels[i].DropGuest(this.channelProxies[i].TaskToPerform == DssChannelTask.DROP_AND_OPEN);
                    this.hostRoot.GuestLeftDss(i);
                }
            }

            /// Then handle any other channels.
            for (int i = 0; i < this.sessions.Length; i++)
            {
                if (this.channelProxies[i].TaskToPerform == DssChannelTask.CLOSE)
                {
                    /// Close the channel.
                    this.channels[i].CloseChannel();
                }
                else if (this.channelProxies[i].TaskToPerform == DssChannelTask.OPEN)
                {
                    /// Open the channel.
                    this.channels[i].OpenChannel();
                }
                else if (this.channelProxies[i].TaskToPerform != DssChannelTask.DROP_AND_OPEN &&
                         this.channelProxies[i].TaskToPerform != DssChannelTask.DROP_AND_CLOSE)
                {
                    /// No task to perform on the channel just send the setup step request.
                    if (this.channels[i].CurrentState == this.channels[i].Engaged)
                    {
                        SetupStep currStep = this.hostRoot.GetStep(i);
                        if (currStep.State == SetupStepState.READY || currStep.State == SetupStepState.ERROR)
                        {
                            currStep.Reset();
                        }
                        DssChannelState[] chStates = new DssChannelState[this.channels.Length];
                        for (int j = 0; j < channels.Length; j++)
                        {
                            if (this.channelProxies[j].TaskToPerform == DssChannelTask.OPEN ||
                                this.channelProxies[j].TaskToPerform == DssChannelTask.DROP_AND_OPEN)
                            {
                                chStates[j] = DssChannelState.CHANNEL_OPENED;
                            }
                            else if (this.channelProxies[j].TaskToPerform == DssChannelTask.CLOSE ||
                                     this.channelProxies[j].TaskToPerform == DssChannelTask.DROP_AND_CLOSE)
                            {
                                chStates[j] = DssChannelState.CHANNEL_CLOSED;
                            }
                            else
                            {
                                if (this.channels[j].CurrentState == this.channels[j].Opened)
                                {
                                    chStates[j] = DssChannelState.CHANNEL_OPENED;
                                }
                                else if (this.channels[j].CurrentState == this.channels[j].Closed)
                                {
                                    chStates[j] = DssChannelState.CHANNEL_CLOSED;
                                }
                                else if (this.channels[j].CurrentState == this.channels[j].Engaged)
                                {
                                    chStates[j] = DssChannelState.GUEST_CONNECTED;
                                }
                                else
                                {
                                    throw new DssException("Unexpected channel state!");
                                }
                            }
                        }

                        int[] leftList = null;
                        int[] lostList = null;
                        this.hostRoot.GetGuestEvents(out leftList, out lostList);
                        RCPackage[] packagesToSend = currStep.CreateRequest(this.channelProxies[i].OutgoingPackages != null ?
                                                                            this.channelProxies[i].OutgoingPackages :
                                                                            new RCPackage[0] {
                        },
                                                                            leftList,
                                                                            lostList,
                                                                            chStates);
                        foreach (RCPackage pckg in packagesToSend)
                        {
                            this.hostRoot.Lobby.SendControlPackage(pckg, i + 1);
                        }
                        this.sessions[i].SetupStepRequestSent();
                    }
                }
            } /// end-for (int i = 0; i < this.channelProxies.Length; i++)
        }