Beispiel #1
0
 // The custom handler for interpreting various event types from TServer
 private void TsHandler(object sender, TServerBufferEventArgs e)
 {
     // Ringing call
     if (e.EventClass == Csta.CSTAUNSOLICITED && e.EventType == Csta.CSTA_DELIVERED)
     {
         isRinging();
     }
     // Disconnected call
     else if (e.EventClass == Csta.CSTAUNSOLICITED && e.EventType == Csta.CSTA_CONNECTION_CLEARED)
     {
         isDisconnected();
     }
     // Connected call
     else if (e.EventClass == Csta.CSTAUNSOLICITED && e.EventType == Csta.CSTA_ESTABLISHED)
     {
         isConnected();
     }
     // Dialed call
     else if (e.EventClass == Csta.CSTAUNSOLICITED && e.EventType == Csta.CSTA_NETWORK_REACHED)
     {
         isDialed();
     }
     // Message waiting indicator update
     else if (e.EventClass == Csta.CSTACONFIRMATION && e.EventType == Csta.CSTA_QUERY_MWI_CONF)
     {
         mwiStatus();
     }
 }
Beispiel #2
0
        // Check the TServer event buffer
        public void checkTServer()
        {
            // Define the mandatory (unused) private data buffer
            Csta.PrivateData_t privData = new Csta.PrivateData_t();
            privData.vendor = "MERLIN                          ".ToCharArray();
            privData.length = 4;
            privData.data   = "N".ToCharArray();

            // Define the event buffer that contains data passed back from TServer
            eventBuf = new Csta.EventBuf_t();
            ushort numEvents    = 0;
            ushort eventBufSize = (ushort)Csta.CSTA_MAX_HEAP;

            // Poll the event queue to see if any call events are occurring
            try
            {
                int polledEvent = Csta.acsGetEventPoll(acsHandle, ref eventBuf, ref eventBufSize, ref privData, ref numEvents);
            }
            catch (System.Exception eEventPoll)
            {
                // If we can't get back a confirmation record the error and inform the user
                MessageBox.Show("There was a TServer error. Logging the incident and continuing the application.", "TServer Error");
                if (!EventLog.SourceExists(strSource))
                {
                    EventLog.CreateEventSource(strSource, strLog);
                }
                EventLog.WriteEntry(strSource, eEventPoll.Message.ToString(), EventLogEntryType.Warning, 234);
                return;
            }

            // Parse out the data elements in the event buffer...

            // The event header
            UInt32 numAcsHandle  = BitConverter.ToUInt32(eventBuf.data, 0);
            ushort numEventClass = BitConverter.ToUInt16(eventBuf.data, 4);
            ushort numEventType  = BitConverter.ToUInt16(eventBuf.data, 6);

            TServerBufferEventArgs args = new TServerBufferEventArgs(numEventClass, numEventType);

            this.TServerBufferPoll(this, args);
        }