public override void Step(OAIEvent oaiEvent)
        {
            // Don't initialise if already connected
            // Or if there was no device specified
            if (Connected || null == Device)
            {
                return;
            }

            switch (this.Stage)
            {
                case STAGE_START:
                    {
                        // Confirm we connected to the phone system
                        // 000,RS,0,02:04,070515,V10.20,V6.0.11.113,3,0,1,3,1
                        if (STAGE_SEGMENT_NULL == this.StageSegment &&
                            0 == "RS".CompareTo(oaiEvent.Event()))
                        {
                            this.StageSegment |= STAGE_START_SEGMENT_RS;
                        }
                        // Confirm we have finished syncing
                        // 001,RD,0,
                        else if (STAGE_START_SEGMENT_RS == this.StageSegment &&
                            0 == "RD".CompareTo(oaiEvent.Event()))
                        {
                            this.StageSegment = STAGE_SEGMENT_NULL;
                            this.Stage = STAGE_NODE_AWARE;
                            OAIWriteQueue.Relay().Line = (LastPacket = new OAINodeAware());
                        }
                        break;
                }

                case STAGE_NODE_AWARE:
                {
                    // Confirming we are node aware
                    // 002,CF,_NA,1,0,1
                    if (LastPacket.Confirmation(oaiEvent))
                    {
                        this.Stage = STAGE_STATION_MONITOR;
                        OAIWriteQueue.Relay().Line = (LastPacket = new OAIMonitorStart(
                            Device, OAIMonitorStart.MONITOR_TYPE_DEVICE,
                            new string[]{ "A:FFFF", "C:FFFF", "F:FFFF" }));
                    }
                    break;
                }

                case STAGE_STATION_MONITOR:
                {
                    // Confirming we are monitoring calls by device
                    // 004,CF,_MS,3,0,0002,000243,1:,000244,2:,S:00FE
                    if (LastPacket.Confirmation(oaiEvent))
                    {
                        OAIWriteQueue.Relay().Line = (LastPacket = new OAIQueryListExtended(0,17,1));
                        Connected = true;
                    }
                    break;
                }
            }
        }
 /**
  *
  */
 public void Finished(OAIEvent evt)
 {
     if (LastPacket.Confirmation(evt))
     {
         // Restore any packets which we may have had
         // left from a disconnect event
         OAIWriteQueue.Relay().ApplyStash();
         Connected = true;
     }
 }
        public override void Step(OAIEvent evt)
        {
            // Don't initialise if already connected!
            if (Connected)
            {
                return;
            }

            switch (Stage)
            {
                case STAGE_START:
                {
                    // Confirm we connected to the phone system
                    // 000,RS,0,02:04,070515,V10.20,V6.0.11.113,3,0,1,3,1

                    // Then confirm we have finished syncing
                    // 001,RD,0,
                    NodeAware(evt, STAGE_NODE_AWARE);
                    return;
                }

                case STAGE_NODE_AWARE:
                {
                    // Confirming we are node aware
                    // 002,CF,_NA,1,0,1
                    StationMonitor(evt, STAGE_STATION_MONITOR);
                    return;
                }

                case STAGE_STATION_MONITOR:
                {
                    // Confirming we are monitoring all stations
                    // 003,CF,_MS,2,0,0242 ... 000076,1761,000077,1762 ...
                    // ... A:00FC,C:FFFE,F:1FFF
                    SystemMonitor(evt, STAGE_SYSTEM_MONITOR);
                    return;
                }

                case STAGE_SYSTEM_MONITOR:
                {
                    // Confirming we are monitoring calls by device
                    // 004,CF,_MS,3,0,0002,000243,1:,000244,2:,S:00FE
                    QueryAgents(evt, STAGE_SYSTEM_QUERY_AGENTS);
                    return;
                }

                case STAGE_SYSTEM_QUERY_AGENTS:
                {
                    //
                    //
                    QueryStations(evt, STAGE_SYSTEM_QUERY_STATIONS);
                    return;
                }

                case STAGE_SYSTEM_QUERY_STATIONS:
                {
                    //
                    //
                    QueryHuntGroups(evt, STAGE_SYSTEM_QUERY_HUNTS);
                    break;
                }

                case STAGE_SYSTEM_QUERY_HUNTS:
                {
                    //
                    //
                    QueryFeatures(evt, STAGE_SYSTEM_QUERY_FEATURES);
                    break;
                }

                case STAGE_SYSTEM_QUERY_FEATURES:
                {
                    //
                    //
                    QueryDND(evt, STAGE_SYSTEM_QUERY_AGENT);
                    break;
                }

                case STAGE_SYSTEM_QUERY_AGENT:
                {
                    QueryAgent(evt, STAGE_FINISHED);
                    break;
                }

                // All setup events finished
                case STAGE_FINISHED:
                {
                    Finished(evt);

                    // Build the base data set
                    if (Connected)
                    {
                        DataBuilt = true;
                    }

                    break;
                }
            }
        }
 public bool Confirmation(OAIEvent oaiEvent)
 {
     return (Invoke == oaiEvent.Invoke() &&
         0 == Command.CompareTo(oaiEvent.Command()) &&
         0 == "CF".CompareTo(oaiEvent.Event()));
 }
        public static void ProcessEvent(OAIEvent packet)
        {
            if (null == packet)
            {
                return;
            }

            // Confirmation Packets
            if (packet is OAIConfirmation)
            {
                ProcessConfirmation((OAIConfirmation)packet);
            }

            // Agent Packets
            if (packet is OAIAgentEvent)
            {
                ProcessAgentEvent((OAIAgentEvent)packet);
            }

            // Call Packets
            if (packet is OAICall)
            {
                ProcessCallEvent((OAICall)packet);
            }

            // Feature Packets
            if (packet is OAIFeature)
            {
                ProcessCallFeature((OAIFeature)packet);
            }

            // Gateway Packets
            if (packet is OAIGateway)
            {
                ProcessGateway((OAIGateway)packet);
            }

            // Gateway Packets
            if (packet is OAIMisc)
            {
                ProcessMisc((OAIMisc)packet);
            }

            // System Packets
            if (packet is OAISystem)
            {
                ProcessSystem((OAISystem)packet);
            }
        }
 public void NodeAware(OAIEvent evt, int next)
 {
     if (STAGE_SEGMENT_NULL == this.StageSegment &&
         0 == "RS".CompareTo(evt.Event()))
     {
         this.StageSegment |= STAGE_START_SEGMENT_RS;
     }
     else if (STAGE_START_SEGMENT_RS == this.StageSegment &&
         0 == "RD".CompareTo(evt.Event()))
     {
         this.StageSegment = STAGE_SEGMENT_NULL;
         this.Stage = next;
         OAIWriteQueue.Relay().Line = (LastPacket = new OAINodeAware());
     }
 }
 public abstract void Step(OAIEvent oaiEvent);
 public void SystemMonitor(OAIEvent evt, int next)
 {
     if (LastPacket.Confirmation(evt))
     {
         this.Stage = next;
         OAIWriteQueue.Relay().Line = (LastPacket = new OAIMonitorStart(
             OAIMonitorStart.MONITOR_TYPE_SYSTEM,
             new string[1] { "S:FFFF" }));
     }
 }
 public void QueryStations(OAIEvent evt, int next)
 {
     if (LastPacket.Confirmation(evt))
     {
         this.Stage = next;
         OAIWriteQueue.Relay().Line = (LastPacket = new OAIQueryListExtended(
             OAIQueryListExtended.LIST_TYPE_STATION_LIST,
             OAIQueryListExtended.MASK_STATION_LIST_USER |
             OAIQueryListExtended.MASK_STATION_LIST_IS_ADMIN |
             OAIQueryListExtended.MASK_STATION_LIST_DEVICE_TYPE));
     }
 }
 public void StationMonitor(OAIEvent evt, int next)
 {
     if (LastPacket.Confirmation(evt))
     {
         this.Stage = next;
         OAIWriteQueue.Relay().Line = (LastPacket = new OAIMonitorStart(
             OAIMonitorStart.MONITOR_TYPE_ALL_STATIONS,
             new string[3] { "A:FFFF", "C:FFFF", "F:FFFF" }));
     }
 }
 /**
  *
  */
 public void QueryHuntGroups(OAIEvent evt, int next)
 {
     if (LastPacket.Confirmation(evt))
     {
         this.Stage = next;
         OAIWriteQueue.Relay().Line = (LastPacket = new OAIQueryListExtended(
             OAIQueryListExtended.LIST_TYPE_HUNT_GROUP_LIST,
             OAIQueryListExtended.MASK_STATION_LIST_USER |
             OAIQueryListExtended.MASK_HUNT_GROUP_LIST_DESC));
     }
 }
 /**
  *
  */
 public void QueryFeatures(OAIEvent evt, int next)
 {
     if (LastPacket.Confirmation(evt))
     {
         this.Stage = next;
         OAIWriteQueue.Relay().Line = (LastPacket = new OAIQueryListExtended(
             OAIQueryListExtended.LIST_TYPE_FEATURE_LIST,
             OAIQueryListExtended.MASK_FEATURE_LIST_FEAT_NUM |
             OAIQueryListExtended.MASK_FEATURE_LIST_FEAT_NAME |
             OAIQueryListExtended.MASK_FEATURE_LIST_IS_ADMIN |
             OAIQueryListExtended.MASK_FEATURE_LIST_IS_DIR |
             OAIQueryListExtended.MASK_FEATURE_LIST_IS_DIAG |
             OAIQueryListExtended.MASK_FEATURE_LIST_IS_TOGGLE));
     }
 }
 /**
  *
  */
 public void QueryDND(OAIEvent evt, int next)
 {
     if (LastPacket.Confirmation(evt))
     {
         this.Stage = next;
         OAIWriteQueue.Relay().Line = (LastPacket = new OAIQueryListExtended(
             OAIQueryListExtended.LIST_TYPE_DND_LIST,
             OAIQueryListExtended.MASK_DND_LIST_MESSAGE));
     }
 }
 public void QueryAgents(OAIEvent evt, int next)
 {
     if (LastPacket.Confirmation(evt))
     {
         this.Stage = next;
         OAIWriteQueue.Relay().Line = (LastPacket = new OAIQueryListExtended(
             OAIQueryListExtended.LIST_TYPE_ACD_AGENT,
             OAIQueryListExtended.MASK_ACD_AGENT_DESC));
     }
 }
 /**
  *
  */
 public void QueryAgent(OAIEvent evt, int next)
 {
     if (LastPacket.Confirmation(evt))
     {
         this.Stage = next;
         OAIWriteQueue.Relay().Line = (LastPacket = new OAIQueryHuntGroup(Config.MasterHuntGroup, true));
     }
 }