Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/smpp-sharp-lib.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'SmppServerLib/_SmppPduBindRespBase.cs')
-rw-r--r--SmppServerLib/_SmppPduBindRespBase.cs46
1 files changed, 46 insertions, 0 deletions
diff --git a/SmppServerLib/_SmppPduBindRespBase.cs b/SmppServerLib/_SmppPduBindRespBase.cs
new file mode 100644
index 0000000..fd38139
--- /dev/null
+++ b/SmppServerLib/_SmppPduBindRespBase.cs
@@ -0,0 +1,46 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Flex.Cluster.Smpp
+{
+ public abstract class SmppPduBindRespBase : SmppPdu
+ {
+ abstract protected SmppCommandType GetCommandType();
+
+ uint offsetSystemId, offsetOptionalParameters;
+
+ public string SystemId
+ {
+ get { return ReadCString(offsetSystemId); }
+ }
+ public SmppOptionalParameter[] OptionalParameters
+ {
+ get { return ReadOptionalParameters(offsetOptionalParameters); }
+ }
+
+ public SmppPduBindRespBase(SmppCommandType commandType, uint sequenceId, SmppCommandStatus status, string systemId, SmppOptionalParameter[] optionalParameters = null)
+ : base(commandType, status, sequenceId)
+ {
+ if (commandType != GetCommandType()) throw new Exception("Invaid command ID");
+
+ if (systemId.Length > 15) throw new ArgumentOutOfRangeException("systemId");
+ offsetSystemId = CurrentOffset;
+ WriteCString(systemId);
+
+ offsetOptionalParameters = CurrentOffset;
+ if (optionalParameters != null)
+ WriteOptionalParameters(optionalParameters);
+ }
+
+ public SmppPduBindRespBase(byte[] bytes) : this(bytes, (uint)bytes.Length) {}
+ public SmppPduBindRespBase(byte[] bytes, uint length)
+ : base(bytes, length)
+ {
+ if (CommandId != GetCommandType()) throw new Exception("Invaid command ID");
+ offsetSystemId = 12;
+ offsetOptionalParameters = FindCStringEnd(offsetSystemId);
+ }
+ }
+}