Ejemplo n.º 1
0
        public void connect(string tgtFqlid)
        {
            Log.Write(LogLevel.Info, "Received Connection Open to " + tgtFqlid);
            if (thisEventHorizon != null)
            {
                if (!_currentDirection)
                {
                    thisEventHorizon.Open(tgtFqlid);
                }
                else
                {
                    thisEventHorizon.Open(null);
                }
            }

            // If it's an outgoing gate, time out after the given duration.
            // Incoming gates are timed out by their counterpart.
            if (!_currentDirection)
            {
                double oldTs = _connectionTimeStamp;
                Timer.Create(_wormhole_duration, () => { timeoutGate(oldTs); });
            }

            thisGateControl.DoReportState(GateState.Connected);
        }
Ejemplo n.º 2
0
        // DialSequenceStep. Started with DialSequenceStep(0,0,1) to run the dialup for the given sequence
        public void DialSequenceStep(int seqIndex, int currentLit, int direction)
        {
            // If we ran through the sequence, open up.
            if (seqIndex == _currentTargetSeqNumbers.Length)
            {
                SendConnect();
                return;
            }

            // Target symbol for this chevron reached, light corresponding chevron, advance with next chevron.
            // Or open the gate if we got finished.
            if (currentLit == _currentTargetSeqNumbers[seqIndex])
            {
                symbolLitState[currentLit] = true;
                SendLightChevron(seqIndex, false);
                Timer.Create(1.0, () => { DialSequenceStep(seqIndex + 1, currentLit, -direction); });
                return;
            }

            // Return old light to previous state (not off - it might have been already on for a previous chevron)
            DoLight(symbols, currentLit, symbolLitState[currentLit]);

            // Select the 'next' symbol, according to direction, wrap around
            currentLit += direction;
            if (currentLit < 0)
            {
                currentLit = symbols.Count - 1;
            }
            else if (currentLit >= symbols.Count)
            {
                currentLit = 0;
            }

            DoLight(symbols, currentLit, true);

            // And continue spinning.
            Timer.Create(0.2, () => { DialSequenceStep(seqIndex, currentLit, direction); });
        }