Example #1
0
 public CapiOutMessage()
 {
     m_Header = new CapiMessageHeader();
 }
Example #2
0
 public CapiInMessage(byte[] lbData)
 {
     m_Header = new CapiMessageHeader(lbData, 0);
 }
Example #3
0
 public CapiInMessage(byte[] lbData, int liOffset)
 {
     m_Header = new CapiMessageHeader(lbData, liOffset);
 }
Example #4
0
        /// <summary>
        /// Thread-In-Routine
        /// </summary>
        private void MessageInThread()
        {
            CapiInMessage  loInMessage  = null;
            CapiOutMessage loOutMessage = null;

            while (Active)
            {
                CAPI_WAIT_FOR_SIGNAL((int)this.m_AppID);

                // Neue Nachricht auslesen
                IntPtr loPtr    = IntPtr.Zero;
                int    liResult = CAPI_GET_MESSAGE(this.m_AppID, out loPtr);

                int    liSize = (int)Marshal.ReadByte(loPtr);
                byte[] lbMsg  = new byte[liSize];

                Marshal.Copy(loPtr, lbMsg, 0, liSize);
                CapiMessageHeader loHeader = new CapiMessageHeader(lbMsg, 0);

                if (loHeader.SubCommand == CapiMessages_SubCommands_Enum.CONF)
                {
                    switch (loHeader.Command)
                    {
                    // Messages concerning the signaling protocol
                    case CapiMessages_Commands_Enum.CONNECT:     // local confirmation of the request
                    {
                        loInMessage = (CapiInMessage) new CONNECT_CONF(lbMsg, 0);
                    }
                    break;

                    case CapiMessages_Commands_Enum.DISCONNECT:     // local confirmation of the request
                    {
                        loInMessage = (CapiInMessage) new DISCONNECT_CONF(lbMsg, 0);
                    }
                    break;

                    case CapiMessages_Commands_Enum.ALERT:     // local confirmation of the request
                    {
                        loInMessage = (CapiInMessage) new ALERT_CONF(lbMsg, 0);
                    }
                    break;

                    case CapiMessages_Commands_Enum.INFO:     // local confirmation of the request
                    {
                        loInMessage = (CapiInMessage) new INFO_CONF(lbMsg, 0);
                    }
                    break;


                    // Messages concerning logical connections
                    case CapiMessages_Commands_Enum.CONNECT_B3:     // local confirmation of the request
                    {
                        loInMessage = (CapiInMessage) new CONNECT_B3_CONF(lbMsg, 0);
                    }
                    break;

                    case CapiMessages_Commands_Enum.DISCONNECT_B3:     // local confirmation of the request
                    {
                        loInMessage = (CapiInMessage) new DISCONNECT_B3_CONF(lbMsg, 0);
                    }
                    break;

                    case CapiMessages_Commands_Enum.DATA_B3:     // local confirmation of the request
                    {
                        loInMessage = (CapiInMessage) new DATA_B3_CONF(lbMsg, 0);
                    }
                    break;

                    case CapiMessages_Commands_Enum.RESET_B3:     // local confirmation of the request
                    {
                        loInMessage = (CapiInMessage) new RESET_B3_CONF(lbMsg, 0);
                    }
                    break;


                    // Administrative and other messages
                    case CapiMessages_Commands_Enum.LISTEN:     // local confirmation of the request
                    {
                        loInMessage = (CapiInMessage) new LISTEN_CONF(lbMsg, 0);
                    }
                    break;

                    case CapiMessages_Commands_Enum.FACILITY:     // local confirmation of the request
                    {
                        loInMessage = (CapiInMessage) new FACILITY_CONF(lbMsg, 0);
                    }
                    break;

                    case CapiMessages_Commands_Enum.SELECT_B_PROTOCOL:     // local confirmation of the request
                    {
                        loInMessage = (CapiInMessage) new SELECT_B_PROTOCOL_CONF(lbMsg, 0);
                    }
                    break;

                    case CapiMessages_Commands_Enum.MANUFACTURER:     // manufacturer-specific operation
                    {
                        loInMessage = (CapiInMessage) new MANUFACTURER_CONF(lbMsg, 0);
                    }
                    break;

                    case CapiMessages_Commands_Enum.INTEROPERABILITY:     // interoperability operation
                    {
                        loInMessage = (CapiInMessage) new INTEROPERABILITY_CONF(lbMsg, 0);
                    }
                    break;


                    default:
                        throw new Exception("Unknown message received as confimation.");
                    }

                    loInMessage.Header = loHeader;

                    onReceive(loInMessage, null);
                }


                // Messages needed to be replied
                else if (loHeader.SubCommand == CapiMessages_SubCommands_Enum.IND)
                {
                    switch (loHeader.Command)
                    {
                    // Messages concerning the signaling protocol
                    case CapiMessages_Commands_Enum.CONNECT:     // indicates an incoming physical connection
                    {
                        loInMessage  = (CapiInMessage) new CONNECT_IND(lbMsg, 0);
                        loOutMessage = (CapiOutMessage) new CONNECT_RESP();
                        //// Preparing
                    }
                    break;

                    case CapiMessages_Commands_Enum.CONNECT_ACTIVE:     // indicates the activation of a physical connection
                    {
                        loInMessage  = (CapiInMessage) new CONNECT_ACTIVE_IND(lbMsg, 0);
                        loOutMessage = (CapiOutMessage) new CONNECT_ACTIVE_RESP();
                        //// Preparing
                    }
                    break;

                    case CapiMessages_Commands_Enum.DISCONNECT:     // indicates the clearing of a physical connection
                    {
                        loInMessage  = (CapiInMessage) new DISCONNECT_IND(lbMsg, 0);
                        loOutMessage = (CapiOutMessage) new DISCONNECT_RESP();
                        //// Preparing
                    }
                    break;

                    case CapiMessages_Commands_Enum.INFO:     // indicates specified signaling information
                    {
                        loInMessage  = (CapiInMessage) new INFO_IND(lbMsg, 0);
                        loOutMessage = (CapiOutMessage) new INFO_RESP();
                        //// Preparing
                    }
                    break;


                    // Messages concerning logical connections
                    case CapiMessages_Commands_Enum.CONNECT_B3:     // indicates an incoming logical connection
                    {
                        loInMessage  = (CapiInMessage) new CONNECT_B3_IND(lbMsg, 0);
                        loOutMessage = (CapiOutMessage) new CONNECT_B3_RESP();
                        //// Preparing
                    }
                    break;

                    case CapiMessages_Commands_Enum.CONNECT_B3_ACTIVE:     // indicates the activation of a logical connection
                    {
                        loInMessage  = (CapiInMessage) new CONNECT_B3_ACTIVE_IND(lbMsg, 0);
                        loOutMessage = (CapiOutMessage) new CONNECT_B3_ACTIVE_RESP();
                        //// Preparing
                    }
                    break;

                    case CapiMessages_Commands_Enum.CONNECT_B3_T90_ACTIVE:     // indicates switching from T.70NL to T.90NL
                    {
                        loInMessage  = (CapiInMessage) new CONNECT_B3_T90_ACTIVE_IND(lbMsg, 0);
                        loOutMessage = (CapiOutMessage) new CONNECT_B3_T90_ACTIVE_RESP();
                        //// Preparing
                    }
                    break;

                    case CapiMessages_Commands_Enum.DISCONNECT_B3:     // indicates the clearing down of a logical connection
                    {
                        loInMessage  = (CapiInMessage) new DISCONNECT_B3_IND(lbMsg, 0);
                        loOutMessage = (CapiOutMessage) new DISCONNECT_B3_RESP();
                        //// Preparing
                    }
                    break;

                    case CapiMessages_Commands_Enum.DATA_B3:     // indicates incoming data over a logical connection
                    {
                        loInMessage  = (CapiInMessage) new DATA_B3_IND(lbMsg, 0);
                        loOutMessage = (CapiOutMessage) new DATA_B3_RESP();
                        //// Preparing
                    }
                    break;

                    case CapiMessages_Commands_Enum.RESET_B3:     // indicates the resetting of a logical connection
                    {
                        loInMessage  = (CapiInMessage) new RESET_B3_IND(lbMsg, 0);
                        loOutMessage = (CapiOutMessage) new RESET_B3_RESP();
                        //// Preparing
                    }
                    break;


                    // Administrative and other messages
                    case CapiMessages_Commands_Enum.FACILITY:     // indicates additional facilities (e.g. ext. equipment)
                    {
                        loInMessage  = (CapiInMessage) new FACILITY_IND(lbMsg, 0);
                        loOutMessage = (CapiOutMessage) new FACILITY_RESP();

                        ((FACILITY_RESP)loOutMessage).Controller_PLCI_NCCI = ((FACILITY_IND)loInMessage).Controller_PLCI_NCCI;
                        ((FACILITY_RESP)loOutMessage).FacilitySelector     = ((FACILITY_IND)loInMessage).FacilitySelector;
                        ////
                        //// Preparing
                    }
                    break;

                    case CapiMessages_Commands_Enum.MANUFACTURER:     // manufacturer-specific operation
                    {
                        loInMessage  = (CapiInMessage) new MANUFACTURER_IND(lbMsg, 0);
                        loOutMessage = (CapiOutMessage) new MANUFACTURER_RESP();

                        ((MANUFACTURER_RESP)loOutMessage).Controller = ((MANUFACTURER_IND)loInMessage).Controller;
                        ((MANUFACTURER_RESP)loOutMessage).ManuID     = ((MANUFACTURER_IND)loInMessage).ManuID;
                        //// Manufacturer dependend data; may need to extend
                    }
                    break;

                    case CapiMessages_Commands_Enum.INTEROPERABILITY:     // interoperability operation
                    {
                        loInMessage  = (CapiInMessage) new INTEROPERABILITY_IND(lbMsg, 0);
                        loOutMessage = (CapiOutMessage) new INTEROPERABILITY_RESP();

                        //// Preparing
                    }
                    break;


                    default:
                        throw new Exception("Unknown message received as indication.");
                    }

                    loOutMessage.Header.AppID         = loHeader.AppID;
                    loOutMessage.Header.MessageNumber = loHeader.MessageNumber;

                    onReceive(loInMessage, loOutMessage);
                }
                else
                {
                    throw new Exception("Unknown message received.");
                }
            }
        }