示例#1
0
        /// <summary> Called to send a query </summary>
        /// <param name="messageId"></param>
        /// <returns> 1 - Successful / 0 - Failed </returns>
        public QuerySm SendQuery(string messageId)
        {
            QuerySm querySm = null;

            try
            {
                // Capture the next transmitter connection
                ESMEConnection smppConnection = NextTransmitterConnection();

                if (smppConnection.Status != ConnectionStatus.Bound)
                {
                    WriteLog("ESMEManager : SendMessage : Warning : Not Connected To The SMPP Server");

                    return(querySm);
                }

                // Send the message
                querySm = smppConnection.SendQuery(messageId);
            }

            catch (Exception exception)
            {
                WriteLog(LogEventNotificationTypes.Email, "ESMEManager : SendMessage : ERROR : {0}", exception.ToString());
            }

            return(querySm);
        }
示例#2
0
        /// <summary> Called to send the message </summary>
        /// <param name="phoneNumber"></param>
        /// <param name="serviceType"></param>
        /// <param name="sourceTon"></param>
        /// <param name="sourceNpi"></param>
        /// <param name="submitDataCoding"></param>
        /// <param name="encodeDataCoding"></param>
        /// <param name="message"></param>
        /// <param name="submitSmList"></param>
        /// <param name="submitSmRespList"></param>
        /// <returns> 1 - Successful / 0 - Failed </returns>
        public int SendMessageLarge(string phoneNumber, string serviceType, Ton sourceTon, Npi sourceNpi, DataCodings submitDataCoding, DataCodings encodeDataCoding, string message, out List <SubmitSm> submitSmList, out List <SubmitSmResp> submitSmRespList)
        {
            int retVal = 0;

            submitSmList     = null;
            submitSmRespList = null;

            try
            {
                // Capture the next transmitter connection
                ESMEConnection smppConnection = NextTransmitterConnection();

                if (smppConnection == null)
                {
                    WriteLog("ESMEManager : SendMessage : Warning : Not Bound To The SMPP Server");

                    return(2);
                }

                // Send the message
                retVal = smppConnection.SendMessageLarge(phoneNumber, serviceType, sourceTon, sourceNpi, submitDataCoding, encodeDataCoding, message, out submitSmList, out submitSmRespList);
            }

            catch (Exception exception)
            {
                WriteLog(LogEventNotificationTypes.Email, "ESMEManager : SendMessage : ERROR : {0}", exception.ToString());
            }

            return(retVal);
        }
示例#3
0
        /// <summary> Called to return the next transmitter for sending </summary>
        /// <returns> SmppConnection </returns>
        private ESMEConnection NextTransmitterConnection()
        {
            ESMEConnection smppConnection = null;

            int totalConnections = Transmitters.Count();

            // We only want a bound connection. We will try them all
            for (int connection = 0; connection < totalConnections; ++connection)
            {
                lock (Transmitters)
                {
                    smppConnection = Transmitters[NextTransmitter];

                    if (++NextTransmitter > Transmitters.Count())
                    {
                        NextTransmitter = 1;
                    }

                    if (smppConnection.Status == ConnectionStatus.Bound)
                    {
                        break;
                    }

                    smppConnection = null;
                }
            }

            return(smppConnection);
        }
示例#4
0
        /// <summary> Called to add a transmitter connection </summary>
        /// <param name="connectionId"></param>
        /// <param name="host"></param>
        /// <param name="port"></param>
        /// <param name="userName"></param>
        /// <param name="password"></param>
        /// <param name="logKey"></param>
        /// <param name="defaultEncoding"></param>
        private void AddTransmitterConnection(int connectionId, string host, int port, string userName, string password, string logKey, DataCodings defaultEncoding)
        {
            lock (Transmitters)
            {
                // Create the smppConnection object
                ESMEConnection smppConnection = new ESMEConnection(connectionId, ShortLongCode, ConnectionModes.Transmitter,
                                                                   host, port, userName, password, logKey, defaultEncoding,
                                                                   new ESMEConnection.CONNECTION_EVENT_HANDLER(ConnectionEventConnectionHandler),
                                                                   null,
                                                                   new ESMEConnection.RECEIVED_GENERICNACK_HANDLER(ReceivedGenericNackConnectionHandler),
                                                                   new ESMEConnection.SUBMIT_MESSAGE_HANDLER(SubmitMessageConnectionHandler),
                                                                   new ESMEConnection.QUERY_MESSAGE_HANDLER(QueryMessageConnectionHandler),
                                                                   new ESMEConnection.LOG_EVENT_HANDLER(LogEventConnectionHandler),
                                                                   new ESMEConnection.PDU_DETAILS_EVENT_HANDLER(PduDetailsConnectionHandler));

                // Add the connection to the list
                Transmitters.Add(connectionId, smppConnection);
            }
        }
示例#5
0
        /// <summary> Called to add a transmitter connection </summary>
        /// <param name="connectionId"></param>
        /// <param name="host"></param>
        /// <param name="port"></param>
        /// <param name="userName"></param>
        /// <param name="password"></param>
        /// <param name="logKey"></param>
        /// <param name="defaultEncoding"></param>
        private void AddTransmitterConnection(int connectionId, string host, int port, string userName, string password, string logKey, DataCodings defaultEncoding)
        {
            lock (Transmitters)
            {
                // Create the smppConnection object
                ESMEConnection smppConnection = new ESMEConnection(connectionId, ShortLongCode, ConnectionModes.Transmitter,
                                                                   host, port, userName, password, logKey, defaultEncoding,
                                                                   new ESMEConnection.CONNECTION_EVENT_HANDLER(ConnectionEventConnectionHandler),
                                                                   null,
                                                                   new ESMEConnection.RECEIVED_GENERICNACK_HANDLER(ReceivedGenericNackConnectionHandler),
                                                                   new ESMEConnection.SUBMIT_MESSAGE_HANDLER(SubmitMessageConnectionHandler),
                                                                   new ESMEConnection.QUERY_MESSAGE_HANDLER(QueryMessageConnectionHandler),
                                                                   new ESMEConnection.LOG_EVENT_HANDLER(LogEventConnectionHandler),
                                                                   new ESMEConnection.PDU_DETAILS_EVENT_HANDLER(PduDetailsConnectionHandler));

                // Add the connection to the list
                Transmitters.Add(connectionId, smppConnection);
            }
        }