/// <summary> Called to create a PduBindResp object </summary> /// <param name="defaultEncoding"></param> /// <param name="buf"></param> /// <param name="offset"></param> /// <returns> PduBindResp </returns> public static BindSmResp Create(DataCodings defaultEncoding, SmppBuffer buf, ref int offset) { BindSmResp bindResp = new BindSmResp(defaultEncoding); try { int start_offset = offset; buf.ExtractHeader(bindResp, ref offset); bindResp.SystemId = buf.ExtractCString(ref offset); while (offset - start_offset < bindResp.Length) { bindResp.Optional.Add(buf.ExtractTLV(ref offset)); } } catch { bindResp = null; } return(bindResp); }
/// <summary> Called to authenticate the system </summary> private bool Bind() { WriteLog("ESMEConnection : Bind : Started : Host[{0}] Port[{1}]", Host, Port); bool retVal = false; try { // Authenticate to the SMPP Server BindSmResp btrp = Client.Bind(UserName, Password, ConnectionMode); // How did we do switch (btrp.Status) { case CommandStatus.ESME_ROK: IsBound = true; ConnectionEventHandler(LogKey, ConnectionEventTypes.Bound, string.Format("ESMEConnection : Bind : Info : Host[{0}] Port[{1}] Bind Established", Host, Port)); retVal = true; break; default: ConnectionEventHandler(LogKey, ConnectionEventTypes.BindingAttemptFailed, string.Format("ESMEConnection : Bind : ERROR : Host[{0}] Port[{1}] Status[{2}]", Host, Port, btrp.Status.ToString())); break; } } catch (Exception exception) { WriteLog("ESMEConnection : Bind : ERROR : Host[{0}] Port[{1}] Bind Failed {2}", Host, Port, exception.Message); } WriteLog("ESMEConnection : Bind : Completed : Host[{0}] Port[{1}] RetVal[{2}]", Host, Port, retVal); return(retVal); }