Crate rusmppc

Source
Expand description

§Rusmppc

A tokio based SMPP v5 client. use std::{str::FromStr, time::Duration};

 use std::{str::FromStr, time::Duration};

 use futures::StreamExt;
 use rusmpp::{
     types::COctetString,
     values::{Npi, Ton},
 };
 use rusmppc::ConnectionBuilder;

 #[tokio::main]
 async fn main() -> Result<(), Box<dyn std::error::Error>> {
     let (client, mut events) = ConnectionBuilder::new()
         .system_id(COctetString::from_str("NfDfddEKVI0NCxO")?)
         .password(COctetString::from_str("rEZYMq5j")?)
         .system_type(COctetString::empty())
         .addr_ton(Ton::Unknown)
         .addr_npi(Npi::Unknown)
         .address_range(COctetString::empty())
         .transceiver()
         .enquire_link_interval(Duration::from_secs(5))
         .response_timeout(Duration::from_secs(2))
         .connect("127.0.0.1:2775")
         .await?;

     let events_task = tokio::spawn(async move {
         // Listen for events like incoming commands and background errors.
         while let Some(event) = events.next().await {
             println!("{:#?}", event);
         }
     });

     // Unbind and disconnect from the server.
     client.unbind().await?;

     // Wait for the client to terminate.
     client.terminated().await;

     events_task.await?;

     Ok(())
 }

Modules§

error
SMPP client error type.

Structs§

Client
SMPP Client.
ConnectionBuilder
Builder for creating a new SMPP connection.

Enums§

BindMode
SMPP bind modes.
Event
SMPP event.