Skip to content

Commit

Permalink
Improve ISmppClient interface
Browse files Browse the repository at this point in the history
  • Loading branch information
IkerCelorrio committed Dec 13, 2022
1 parent b91ef60 commit b94c5fb
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 7 deletions.
45 changes: 43 additions & 2 deletions AberrantSMPP/ISmppClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@
* along with AberrantSMPP. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic;
using System.Security.Authentication;

using AberrantSMPP.EventObjects;
using AberrantSMPP.Packet;
using AberrantSMPP.Packet.Request;
using AberrantSMPP.Packet.Response;

namespace AberrantSMPP
{
public interface ISmppClient : IDisposable
{
// FIXME: This should expose all that is common to both Smpp client implementations..

/// <summary>
/// The host to bind this ISmppClient to.
/// </summary>
Expand Down Expand Up @@ -99,6 +99,47 @@ public interface ISmppClient : IDisposable
/// </summary>
bool DisableSslRevocationChecking { get; }

/// <summary>
/// Gets or sets the response timeout (in miliseconds)
/// </summary>
/// <value>The response timeout.</value>
TimeSpan ResponseTimeout { get; set; }

/// <summary>
/// Sends a user-specified Pdu(see the RoaminSMPP base library for
/// Pdu types). This allows complete flexibility for sending Pdus.
/// </summary>
/// <param name="packet">The Pdu to send.</param>
/// <returns>The sequence number of the sent PDU, or null if failed.</returns>
uint SendPdu(Pdu packet);

/// <summary>
/// Sends a request and waits for the appropriate response.
/// If no response is received before RequestTimeout seconds, an
/// SmppTimeoutException is thrown.
/// If a response is received w/ CommandStatus != OK, an
/// SmppRequestException is thrown.
/// </summary>
/// <param name="request">The request.</param>
SmppResponse SendAndWait(SmppRequest request);

/// <summary>
/// Sends an SMS message synchronouslly, possibly splitting it on multiple PDUs
/// using the specified segmentation & reassembly method.
/// </summary>
/// <returns>The list of messageIds assigned by remote party to each submitted PDU.</returns>
IEnumerable<SmppResponse> SendAndWait(IEnumerable<SmppRequest> requests);

/// <summary>
/// Sends an SMS message synchronouslly, possibly splitting it on multiple PDUs
/// using the specified segmentation & reassembly method.
/// </summary>
/// <param name="pdu">The pdu.</param>
/// <param name="method">The method.</param>
/// <returns>The list of messageIds assigned by remote party to each submitted PDU.</returns>
IEnumerable<string> SendAndWait(SmppSubmitSm pdu, SmppSarMethod method);


#region events
/// <summary>
/// Event called when the client receives a bind response.
Expand Down
13 changes: 12 additions & 1 deletion AberrantSMPP/SMPPCommunicator.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* AberrantSMPP: SMPP communication library
/* AberrantSMPP: SMPP communication library
* Copyright (C) 2004, 2005 Christopher M. Bouzek
* Copyright (C) 2010, 2011 Pablo Ruiz García <[email protected]>
*
Expand Down Expand Up @@ -1309,6 +1309,17 @@ protected override void Dispose(bool disposing)
}

base.Dispose(disposing);
}

#region explicit ISmppClient adapter methods
TimeSpan ISmppClient.ResponseTimeout
{
get => TimeSpan.FromMilliseconds(ResponseTimeout);
set => ResponseTimeout = (int)value.TotalMilliseconds;
}
SmppResponse ISmppClient.SendAndWait(SmppRequest request) => SendRequest(request);
IEnumerable<SmppResponse> ISmppClient.SendAndWait(IEnumerable<SmppRequest> requests) => SendRequests(requests);
IEnumerable<string> ISmppClient.SendAndWait(SmppSubmitSm pdu, SmppSarMethod method) => Send(pdu, method);
#endregion
}
}
2 changes: 0 additions & 2 deletions TestClient/Facilities/ISmppClientAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ internal interface ISmppClientAdapter : ISmppClient
//void Connect();
//void Disconnect();
bool IsClientReady();
SmppResponse SendAndWait(SmppRequest request);
uint SendPdu(Pdu packet);
SmppClientStatus Status { get; }
}
}
2 changes: 0 additions & 2 deletions TestClient/Facilities/SMPPCommunicatorAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ public void Configure()
// intentionally empty
}

public SmppResponse SendAndWait(SmppRequest request) => SendRequest(request);

public void Start() => _bound = Bind();

public void Stop()
Expand Down

0 comments on commit b94c5fb

Please sign in to comment.