Пример #1
0
        // <SendHelloWorld>
        public static async Task SendHelloWorld()
        {
            using (SmppServer server = new SmppServer(new IPEndPoint(IPAddress.Any, 7777)))
            {
                server.Start();

                using (SmppClient client = new SmppClient())
                {
                    if (await client.Connect("localhost", 7777))
                    {
                        BindResp bindResp = await client.Bind("1", "2");

                        if (bindResp.Header.Status == CommandStatus.ESME_ROK)
                        {
                            var submitResp = await client.Submit(
                                SMS.ForSubmit()
                                .From("111")
                                .To("222")
                                .Coding(DataCodings.UCS2)
                                .Text("Hello World!"));

                            if (submitResp.All(x => x.Header.Status == CommandStatus.ESME_ROK))
                            {
                                client.Logger.Info("Message has been sent.");
                            }
                        }

                        await client.Disconnect();
                    }
                }
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            HttpClient http       = new HttpClient();
            string     webSiteUrl = "http://www.posta.md/ro/tracking?id=RH263108004CN";
            var        response   = http.GetByteArrayAsync(webSiteUrl);
            string     source     = Encoding.GetEncoding("utf-8").GetString(response.Result, 0, response.Result.Length - 1);

            source = WebUtility.HtmlDecode(source);
            HtmlDocument htmlDoc = new HtmlDocument();

            htmlDoc.LoadHtml(source);

            List <HtmlNode> nodes = htmlDoc.DocumentNode.Descendants().Where(w => (w.Name == "div" && w.Attributes["class"] != null) && w.Attributes["class"].Value.Contains("row clearfix")).ToList();

            OrderTracking orderTracking = new OrderTracking();

            foreach (HtmlNode node in nodes)
            {
                orderTracking.AddItem(node);
            }

            SmppServer smppServer = new SmppServer();

            smppServer.ConnectToSmppServerSmsCarrier();
            smppServer.SendSms();

            Console.ReadLine();
        }
        public SMPPGateway()
        {
            _proxyServer                   = new SmppServer(new IPEndPoint(IPAddress.Any, 7776));
            _proxyServer.Name              = "Proxy" + _proxyServer.Name;
            _proxyServer.evClientSubmitSm += WhenReceiveSubmitSmFromClient;

            _proxyClient = new SmppClient();

            _proxyClient.Name = "Proxy" + _proxyClient.Name;

            _proxyClient.evDeliverSm += WhenDeliveryReceiptReceivedFromSMSC;

            _storage.ReceiptReadyForDelivery += WhenReceiptIsReadyForDelivery;
        }
Пример #4
0
        private void Run()
        {
            _server = new SmppServer(new IPEndPoint(IPAddress.Any, 7777));


            _server.evClientConnected += (sender, client) =>
            {
            };
            _server.evClientDisconnected += (sender, client) =>
            {
            };
            _server.evClientSubmitSm += WhenServerReceivesPDU;
            _server.Start();
        }
        public static async Task Run()
        {
            // <Sample>
            using (SmppServer server = new SmppServer(new IPEndPoint(IPAddress.Any, 7777)))
            {
                server.EnabledSslProtocols = SslProtocols.Tls12;
                server.ServerCertificate   = new X509Certificate2("server_certificate.p12", "cert_password");

                server.Start();

                server.evClientConnected += (sender, client) =>
                {
                    var clientCertificate = client.ClientCertificate;
                    //You can validate client certificate and disconnect if it is not valid.
                };

                using (SmppClient client = new SmppClient())
                {
                    client.EnabledSslProtocols = SslProtocols.Tls12;
                    //if required you can be authenticated with client certificate
                    client.ClientCertificates.Add(new X509Certificate2("client_certificate.p12", "cert_password"));

                    if (await client.Connect("localhost", 7777))
                    {
                        BindResp bindResp = await client.Bind("username", "password");

                        if (bindResp.Header.Status == CommandStatus.ESME_ROK)
                        {
                            var submitResp = await client.Submit(
                                SMS.ForSubmit()
                                .From("111")
                                .To("436641234567")
                                .Coding(DataCodings.UCS2)
                                .Text("Hello World!"));

                            if (submitResp.All(x => x.Header.Status == CommandStatus.ESME_ROK))
                            {
                                client.Logger.Info("Message has been sent.");
                            }
                        }

                        await client.Disconnect();
                    }
                }
            }
            //</Sample>
        }
        public static async Task StartApp()
        {
            using (SmppServer server = new SmppServer(new IPEndPoint(IPAddress.Any, 7777)))
            {
                server.evClientBind     += (sender, client, data) => { /*accept all*/ };
                server.evClientSubmitSm += (sender, client, data) => { /*receive all*/ };
                server.Start();

                using (SmppClient client = new SmppClient())
                {
                    await client.Connect("localhost", 7777);

                    await client.Bind("username", "password");

                    Console.WriteLine("Performance: " + await RunTest(client, 50000) + " m/s");
                }
            }
        }
Пример #7
0
        public SmppServerDemo()
        {
            //HOW TO INSTALL LICENSE FILE
            //====================
            //After purchase you will receive Inetlab.SMPP.license file per E-Mail.
            //Add this file into the root of project where you have a reference on Inetlab.SMPP.dll. Change "Build Action" of the file to "Embedded Resource".

            //Set license before using Inetlab.SMPP classes in your code:

            // C#
            // Inetlab.SMPP.LicenseManager.SetLicense(this.GetType().Assembly.GetManifestResourceStream(this.GetType(), "Inetlab.SMPP.license" ));
            //
            // VB.NET
            // Inetlab.SMPP.LicenseManager.SetLicense(Me.GetType().Assembly.GetManifestResourceStream(Me.GetType(), "Inetlab.SMPP.license"))


            InitializeComponent();

            LogManager.SetLoggerFactory(new TextBoxLogFactory(tbLog, LogLevel.Info));



            AppDomain.CurrentDomain.UnhandledException += (sender, args) =>
            {
                LogManager.GetLogger("AppDomain").Fatal((Exception)args.ExceptionObject, "Unhandled Exception");
            };

            _log = LogManager.GetLogger(GetType().Name);

            _server = new SmppServer(new IPEndPoint(IPAddress.Any, int.Parse(tbPort.Text)));
            _server.evClientConnected    += server_evClientConnected;
            _server.evClientDisconnected += server_evClientDisconnected;
            _server.evClientBind         += server_evClientBind;
            _server.evClientSubmitSm     += server_evClientSubmitSm;
            _server.evClientSubmitMulti  += server_evClientSubmitMulti;
            _server.evClientEnquireLink  += ServerOnClientEnquireLink;

            _server.evClientCertificateValidation += OnClientCertificateValidation;

            //Create message composer. It helps to get full text of the concatenated message in the method OnFullMessageReceived
            _messageComposer = new MessageComposer();
            _messageComposer.evFullMessageReceived += OnFullMessageReceived;
            _messageComposer.evFullMessageTimeout  += OnFullMessageTimeout;
        }
Пример #8
0
        public GenerateSms(SmppServer server)
        {
            InitializeComponent();

            // Init fields to last value.
            tbSource.Text      = _sourceAddr;
            tbDest.Text        = _destAddr;
            tbServiceType.Text = _svcType;
            tbMessage.Text     = _message;

            // Load our sessions combo box.
            foreach (SmppSession session in server.CurrentSessions)
            {
                cbSessions.Items.Add(session);
            }
            if (cbSessions.Items.Count > 0)
            {
                cbSessions.SelectedIndex = 0;
            }
        }
Пример #9
0
        private void OnLoad(object sender, EventArgs e)
        {
            InitForm form = new InitForm();

            if (form.ShowDialog() == DialogResult.Cancel)
            {
                this.Close();
            }
            else
            {
                this.SetBounds(this.Left, this.Top, this.Width + 1, this.Height + 1);

                // Pull the data from the init form.
                password_         = form.Password;
                supportedVersion_ = (byte)form.Version;
                nxtMid_           = randGen_.Next(32000);

                // Start the SMPP server
                server_ = new SmppServer(form.SystemID);
                server_.OnNewSession += OnNewSession;
                server_.StartServer(form.Port);
                timer1.Enabled = true;
            }
        }