Ejemplo n.º 1
0
        private void TimelineRunner(object state)
        {
            this.loadedServices.Wait();

            ActiveServices services = null;

            while (true)
            {
                PlaybackEnvironment environment = this.currentEnvironment;
                PlaybackEnvironment previous    = this.previousEnvironment;

                if (this.servicesUpdated)
                {
                    this.lck.Wait();
                    var enabled = this.enabledServices.ToArray();
                    services = new ActiveServices {
                        Audio    = enabled.OfType <IAudioService>().FirstOrDefault(),
                        Lighting = enabled.OfType <ILightingService>().FirstOrDefault(),
                        Storage  = this.storage
                    };
                    this.lck.Release();
                }

                environment?.Tick(services);
                previous?.Tick(services);

                Thread.Sleep(1);
            }
        }
Ejemplo n.º 2
0
        public void Tick(ActiveServices services)
        {
            foreach (PlaybackEnvironmentElement element in this.elements)
            {
                if (!element.IsActive)
                {
                    continue;
                }

                if (this.transitions.TryGetValue(element, out Transition transition))
                {
                    element.Intensity = transition.GetIntensity();
                    if (transition.IsFinished)
                    {
                        this.transitions.TryRemove(element, out Transition v);
                        if (transition.EndingIntensity <= 0)
                        {
                            element.IsActive = false;
                        }
                    }
                }

                element.Tick(services);
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Adds a logic handler to our list so it will receive IQ and message events
 /// </summary>
 /// <param name="log"></param>
 public void AddLogic(Logic log)
 {
     lock (LogicLock)
     {
         ActiveServices.Add(log);
     }
 }
Ejemplo n.º 4
0
        public XMPPClient()
        {
            StreamNegotiationLogic           = new StreamNegotiationLogic(this);
            GenericIQLogic                   = new GenericIQLogic(this);
            RosterLogic                      = new RosterLogic(this);
            PresenceLogic                    = new PresenceLogic(this);
            GenericMessageLogic              = new GenericMessageLogic(this);
            ServiceDiscoveryLogic            = new ServiceDiscoveryLogic(this);
            JingleSessionManager             = new Jingle.JingleSessionManager(this);
            StreamInitiationAndTransferLogic = new StreamInitiationAndTransferLogic(this);
            PersonalEventingLogic            = new PersonalEventingLogic(this);

            lock (LogicLock)
            {
                ActiveServices.Add(StreamNegotiationLogic); /// Handle SASL authentication
                ActiveServices.Add(GenericMessageLogic);
                ActiveServices.Add(GenericIQLogic);         /// Handle pings and other common messages
                ActiveServices.Add(RosterLogic);            /// Handles getting our roster
                ActiveServices.Add(PresenceLogic);
                ActiveServices.Add(ServiceDiscoveryLogic);
                ActiveServices.Add(JingleSessionManager);
                ActiveServices.Add(StreamInitiationAndTransferLogic);
                ActiveServices.Add(PersonalEventingLogic);
            }

            this.OurServiceDiscoveryFeatureList.AddFeature(new feature("http://jabber.org/protocol/disco#items"));
            this.OurServiceDiscoveryFeatureList.AddFeature(new feature("http://jabber.org/protocol/disco#info"));
            this.OurServiceDiscoveryFeatureList.AddFeature(new feature("jabber:x:data"));

            // Jingle features
            this.OurServiceDiscoveryFeatureList.AddFeature(new feature("urn:xmpp:jingle:1"));
            this.OurServiceDiscoveryFeatureList.AddFeature(new feature("urn:xmpp:jingle:transports:ice-udp:0")); // not sure if we want ICE, makes the simple protocol difficult
            this.OurServiceDiscoveryFeatureList.AddFeature(new feature("urn:xmpp:jingle:transports:ice-udp:1"));
            this.OurServiceDiscoveryFeatureList.AddFeature(new feature("urn:xmpp:jingle:transports:raw-udp:0")); // raw udp much simpler
            this.OurServiceDiscoveryFeatureList.AddFeature(new feature("urn:xmpp:jingle:transports:raw-udp:1"));

            this.OurServiceDiscoveryFeatureList.AddFeature(new feature("urn:xmpp:jingle:apps:rtp:1"));
            this.OurServiceDiscoveryFeatureList.AddFeature(new feature("urn:xmpp:jingle:apps:rtp:audio"));
            this.OurServiceDiscoveryFeatureList.AddFeature(new feature("urn:xmpp:jingle:apps:rtp:video"));

            /// si features... not sure about these
            this.OurServiceDiscoveryFeatureList.AddFeature(new feature("http://jabber.org/protocol/si"));
            this.OurServiceDiscoveryFeatureList.AddFeature(new feature("http://jabber.org/protocol/si/profile/file-transfer"));
            this.OurServiceDiscoveryFeatureList.AddFeature(new feature("http://jabber.org/protocol/ibb"));
            this.OurServiceDiscoveryFeatureList.AddFeature(new feature("http://jabber.org/protocol/bytestreams"));


            this.OurServiceDiscoveryFeatureList.AddFeature(new feature("http://jabber.org/protocol/geoloc"));
            this.OurServiceDiscoveryFeatureList.AddFeature(new feature("http://jabber.org/protocol/geoloc+notify"));
            this.OurServiceDiscoveryFeatureList.AddFeature(new feature("http://jabber.org/protocol/tune"));
            this.OurServiceDiscoveryFeatureList.AddFeature(new feature("http://jabber.org/protocol/tune+notify"));
            this.OurServiceDiscoveryFeatureList.AddFeature(new feature("urn:xmpp:avatar:data"));
            this.OurServiceDiscoveryFeatureList.AddFeature(new feature("urn:xmpp:avatar:metadata"));
            //this.OurServiceDiscoveryFeatureList.AddFeature(new feature(""));

            FileTransferManager = new FileTransferManager(this);
        }
Ejemplo n.º 5
0
        public void Tick(ActiveServices services)
        {
            // TODO: Modify to handle a controlling component being the trigger point
            // so that we can determine when to get new positions.

            foreach (ComponentState state in this.componentStates)
            {
                IEnvironmentService service = services.GetService(state.Component);
                if (service == null)
                {
                    continue;
                }

                if (state.NextPrepare == null)
                {
                    state.SetupNext(Element, service, Element.Positioning.GetPosition(random));
                    state.Timer = Stopwatch.StartNew();
                }

                bool updating = state.ShouldUpdate;

                if (Intensity != state.LastIntensity)
                {
                    IPreparedEffect currentEffect;
                    if (updating || state.CurrentEffect == null)
                    {
                        currentEffect = state.NextPrepare?.Result;
                    }
                    else
                    {
                        currentEffect = state.CurrentEffect;
                    }

                    if (currentEffect != null)
                    {
                        service.SetIntensity(currentEffect, Intensity);
                        state.LastIntensity = Intensity;
                    }
                }

                if (updating && state.IsActive)
                {
                    if (state.NextTime == default)
                    {
                        state.IsActive = false;
                        continue;
                    }

                    state.CurrentDescriptor = state.NextDescriptor;
                    service.PlayEffect(state.NextPrepare.Result);
                    state.Timer = Stopwatch.StartNew();
                    state.SetupNext(Element, service, Element.Positioning.GetPosition(random));
                }
            }
        }
Ejemplo n.º 6
0
        public void UnregisterService(Type serviceType)
        {
            if (Services.ContainsKey(serviceType))
            {
                Services.Remove(serviceType);
            }

            if (ActiveServices.ContainsKey(serviceType))
            {
                ActiveServices.Remove(serviceType);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Removes a logic handler from our list.  Logic handlers are automatically removed if they set their state to completed
        /// </summary>
        /// <param name="log"></param>
        /// <returns></returns>
        public bool RemoveLogic(Logic log)
        {
            bool bRet = false;

            lock (LogicLock)
            {
                if (ActiveServices.Contains(log) == true)
                {
                    ActiveServices.Remove(log);
                    bRet = true;
                }
            }
            return(bRet);
        }
Ejemplo n.º 8
0
        public void RegisterService(IService service)
        {
            try
            {
                Services.Add(service.GetType(), service);

                IActiveService active = service as IActiveService;

                if (active != null)
                {
                    ActiveServices.Add(active.GetType(), active);
                }
            }
            catch (ArgumentException ex)
            {
                throw new ArgumentException(string.Format(ErrorMessages.DuplicateServiceMessage, service.GetType().ToString()), ex);
            }
        }
Ejemplo n.º 9
0
        protected virtual bool OnPresence(PresenceMessage pres)
        {
            bool bHandled = false;

            Logic[]      LogicList  = null;
            List <Logic> RemoveList = new List <Logic>();

            lock (LogicLock)
            {
                LogicList = ActiveServices.ToArray();
            }

            foreach (Logic log in LogicList)
            {
                bHandled = log.NewPresence(pres);

                if (log.IsCompleted == true)
                {
                    RemoveList.Add(log);
                }
                if (bHandled == true)
                {
                    break;
                }
            }

            lock (LogicLock)
            {
                foreach (Logic log in RemoveList)
                {
                    if (ActiveServices.Contains(log) == true)
                    {
                        ActiveServices.Remove(log);
                    }
                }
            }
            return(bHandled);
        }
Ejemplo n.º 10
0
        protected virtual void XMPPConnection_OnStanzaReceived(XMPPStanza stanza, object objFrom)
        {
            bool bHandled = false;
            /// See if any of our handlers
            ///
            List <Logic> RemoveList = new List <Logic>();

            lock (LogicLock)
            {
                foreach (Logic log in ActiveServices)
                {
                    bHandled = log.NewXMLFragment(stanza);
                    if (log.IsCompleted == true)
                    {
                        RemoveList.Add(log);
                    }
                    if (bHandled == true)
                    {
                        break;
                    }
                }

                foreach (Logic log in RemoveList)
                {
                    ActiveServices.Remove(log);
                }
            }

            if (bHandled == true)
            {
                return;
            }

            /// Now see if this stanza is a higher level IQ or message
            ///
            try
            {
                XElement        elem = XElement.Parse(stanza.XML);
                XMPPMessageBase msg  = null;
                if (elem.Name == "iq")
                {
                    msg = XMPPMessageFactory.BuildIQ(elem, stanza.XML);
                }
                else if (elem.Name == "message")
                {
                    msg = XMPPMessageFactory.BuildMessage(elem, stanza.XML);
                }
                else if (elem.Name == "presence")
                {
                    msg = XMPPMessageFactory.BuildPresence(elem, stanza.XML);
                    //msg = new PresenceMessage(stanza.XML);
                }
                /// TODO.. log IQ, MESSAGE or PRESENCE event, maybe have an event handler
                ///
                if (msg != null)
                {
                    if (msg is IQ)
                    {
                        bHandled = OnIQ(msg as IQ);
                    }
                    else if (msg is Message)
                    {
                        bHandled = OnMessage(msg as Message);
                    }
                    else if (msg is PresenceMessage)
                    {
                        bHandled = OnPresence(msg as PresenceMessage);
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.ToString());
            }

            if (bHandled == true)
            {
                return;
            }
        }
Ejemplo n.º 11
0
        public ApiResult <EAndPData> GetMockTerminalDetails()
        {
            TerminalDetails terminalDetails = new TerminalDetails()
            {
                credit              = 1,
                debit               = 1,
                autoSettleOverride  = "0",
                autoSettleTime      = "0000",
                autoSettleIndicator = "1",
                timeZone            = "EDT",
                terminalDescription = "Terminal - Omni 396 POS",
                terminalType        = "XPNT",
            };

            var activeServices = new ActiveServices()
            {
                LIDType           = 1,
                LID               = 757365,
                BillingMethodType = 6,
                BillMtdDesc       = "Cost Plus",
                GiftLynk_ON       = true,
                RewardsLynk_ON    = true,
                LastProcessingDt  = System.DateTime.Now,
                Amex_ON           = true,
                Discover_ON       = false,
                Discover_CT21_ON  = true,
                Diner_ON          = false,
                JCB_ON            = false,
                OpenCase          = 2,
                TerminalRental_ON = false,
                PrinterRental_ON  = false,
                PINPadRental_ON   = true,
                SoftDesc          = "VAR Software",
                CreditST_ON       = true,
                DebitST_ON        = true,
                CheckST_ON        = false,
                ACHST_ON          = false,
                LynkAdvantage_ON  = false,
                SICDesc           = "5541 SVC STA",
            };

            var terminalInfo = new TerminalInfo();

            terminalInfo.customerID        = 393727;
            terminalInfo.merchantId        = 570343;
            terminalInfo.terminalId        = "LK429221";
            terminalInfo.businessType      = 2;
            terminalInfo.programType       = 0;
            terminalInfo.activationDt      = DateTime.Now;
            terminalInfo.downLoadDate      = DateTime.Now;
            terminalInfo.sentToStratusDate = DateTime.Now;
            terminalInfo.cspStatusInterval = "2";
            terminalInfo.commType          = 2;
            terminalInfo.statusIndicator   = 1;
            terminalInfo.cutOffTime        = "400";
            terminalInfo.captureType       = 0;
            terminalInfo.defaultNetwork    = 0;
            terminalInfo.originalSO        = 838033;
            terminalInfo.incrementalDt     = DateTime.Now;
            terminalInfo.busTypeDesc       = "Payment";
            terminalInfo.cashAdv           = 0;
            terminalInfo.checkSvc          = 0;
            terminalInfo.credit            = 1;
            terminalInfo.debit             = 0;
            terminalInfo.ebt          = 0;
            terminalInfo.fleet        = 0;
            terminalInfo.pob          = 0;
            terminalInfo.suppLA       = 0;
            terminalInfo.merchantName = "Golden Corral 919";
            terminalInfo.statDesc     = "Active";

            var sensitivityInfo = new SensitivityInfo()
            {
                senLevelDesc     = "Mid Market",
                sensitivityLevel = 4,
            };

            var eandpData = new EAndPData();

            eandpData.activeServices  = activeServices;
            eandpData.terminalInfo    = terminalInfo;
            eandpData.terminalDetails = terminalDetails;
            //  eandpData.terminalSettlementInfo = GetMockTerminalSettlementInfo().Result;
            eandpData.sensitivityInfo = sensitivityInfo;

            ApiResult <EAndPData> expected = new ApiResult <EAndPData>()
            {
                Result = eandpData
            };

            return(expected);
        }