/// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }

                _client.Dispose();
            }
            base.Dispose(disposing);
        }
Ejemplo n.º 2
0
        protected virtual void OnDispose(bool disposing)
        {
            if (disposed)
            {
                return;
            }

            if (disposing)
            {
                anBind = null;
                client.Dispose();
            }
            disposed = true;
        }
Ejemplo n.º 3
0
        /// <summary> Dispose </summary>
        /// <param name="disposing"></param>
        protected void Dispose(bool disposing)
        {
            WriteLog("ESMEConnection : Dispose : Started");

            if (!Disposed)
            {
                // Note disposing has begun
                Disposed = true;

                try
                {
                    WriteLog("ESMEConnection : Dispose : Info : Wait For Connection Thread To Die");

                    // Kill the PerformConnectClient thread
                    ConnectEvent.Set();
                    ConnectionThread.Join(5000);

                    WriteLog("ESMEConnection : Dispose : Info : Disconnect from smpp Started");

                    Client.Dispose();
                    Client = null;

                    WriteLog("ESMEConnection : Dispose : Info : Disconnect from smpp Completed");
                }

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

                // Kill the PerformConnectClient thread
                ConnectEvent.Set();
            }

            WriteLog("ESMEConnection : Dispose : Completed");
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            Common.Logging.LogManager.Adapter = new Common.Logging.Simple.DebugLoggerFactoryAdapter();
            var encSrv = new SmppEncodingService();

            var hexBytes  = "000000dd0000000500000000019182410001013334363439323836383039000501657669636572746961000400000000000000008569643a323533303932393134353232363637333732207375623a30303120646c7672643a303031207375626d697420646174653a3133303932393136353220646f6e6520646174653a3133303932393136353220737461743a44454c49565244206572723a3030303020746578743a1b3c657669534d531b3e0a534d532064652050727565042300030300000427000102001e001332353330393239313435323236363733373200";
            var packet    = StringToByteArray(hexBytes);
            var bodyBytes = packet.Skip(16).ToArray();

            var pdu = PDU.CreatePDU(PDUHeader.Parse(new ByteBuffer(packet), encSrv), encSrv);

            pdu.SetBodyData(new ByteBuffer(bodyBytes));

            var receiptedMessageId = pdu.GetOptionalParamString(JamaaTech.Smpp.Net.Lib.Protocol.Tlv.Tag.receipted_message_id);

            //Assert.AreEqual("253092914522667372", pdu.ReceiptedMessageId);

            _Log.Info("Start");
            //Trace.Listeners.Add(new ConsoleTraceListener());

            smppConfig = GetSmppConfiguration();

            //SMPPEncodingUtil.UCS2Encoding = Encoding.UTF8;

            client = CreateSmppClient(smppConfig);
            client.Start();

            // must wait until connected before start sending
            while (client.ConnectionState != SmppConnectionState.Connected)
            {
                Thread.Sleep(100);
            }

            // Accept command input
            bool bQuit = false;

            do
            {
                // Hit Enter in the terminal once the binds are up to see this prompt

                Console.WriteLine("Commands");
                Console.WriteLine("send 123456 hello");
                Console.WriteLine("quit");
                Console.WriteLine("");

                Console.Write("\n#>");

                string command = Console.ReadLine();
                if (command.Length == 0)
                {
                    continue;
                }

                switch (command.Split(' ')[0].ToString())
                {
                case "quit":
                case "exit":
                case "q":
                    bQuit = true;
                    break;

                default:
                    ProcessCommand(command);
                    break;
                }

                if (bQuit)
                {
                    break;
                }
            } while (true);

            if (client != null)
            {
                client.Dispose();
            }
        }