Пример #1
0
        private void HandleBackgroundCompletion(IPipelineHandlerContext context, EventRecieved message)
        {
            var msg = message.FreeSwitchEvent as BackgroundJob;

            if (msg == null)
            {
                context.SendUpstream(message);
                return;
            }

            BgApiCmd command;

            lock (_pending)
            {
                command = _pending.FirstOrDefault(x => x.Id == msg.JobUid);
                if (command == null)
                {
                    throw new InvalidOperationException("Got a command reply but no pending background job: " + msg);
                }

                _pending.Remove(command);
            }


            context.SendUpstream(new CommandReply(command.Inner, msg.CommandResult.StartsWith("+"), msg.CommandResult));
        }
Пример #2
0
 private void Phy_DataRecieved(object sender, string e)
 {
     DataRecieved?.Invoke(this, e);
     if (e.StartsWith("E"))
     {
         EventRecieved?.Invoke(this, e);
     }
     else
     {
         result = e;
         signal.Release();
     }
 }
Пример #3
0
        public void OnEvent(EventData eventData)
        {
            var rawMessageData = new RawMessageData(eventData.Code, eventData.Parameters[0] as byte[]);

            if (NetworkTrafficState == NetworkTrafficState.Paused)
            {
                optionsBuffer.Enqueue(BufferOption.Event);
                eventsBuffer.Enqueue(rawMessageData);
            }
            else
            {
                EventRecieved?.Invoke(rawMessageData);
            }
        }
Пример #4
0
        public int Empty()
        {
            int itemsDumped = 0;

            lock (s_lock)
            {
                if (null != EventRecieved)
                {
                    itemsDumped   = EventRecieved.GetInvocationList().Length;
                    EventRecieved = null;
                }

                return(itemsDumped);
            }
        }
Пример #5
0
        public int SendEvent(object sender, T newEvent)
        {
            lock (s_lock)
            {
                if (null != EventRecieved)
                {
                    EventRecieved(sender, new BusEventArgs <T>(newEvent));

                    return(EventRecieved.GetInvocationList().Length);
                }
                else
                {
                    return(0);
                }
            }
        }