/// <summary> Dispose </summary> /// <param name="disposing"></param> protected virtual void Dispose(bool disposing) { if (!_Disposed) { if (disposing) { if (_EnquireLinkTimer != null) { _EnquireLinkTimer.Dispose(); _EnquireLinkTimer = null; } _SocketClient.Dispose(); // Wake up any waiting threads lock (SubmitDone) { foreach (EventData eventData in SubmitDone.Values) { eventData.SignalEvent.Set(); } } } _Disposed = true; } }
/// <summary> Called by the timer when it fires </summary> /// <param name="stateInfo"></param> /// <param name="theTimer"></param> private void SendEnquireLink(object stateInfo, SynchronousTimer theTimer) { try { if (_Status != ConnectionStatus.Bound) { OnError("SendEnquireLink: Connection Not Established or Bound"); return; } TimeSpan diff; lock (_LastPduLock) { diff = DateTime.Now - _LastPdu; } // If it has been more than 40 seconds since we talked with the server do this if (diff.TotalSeconds > 40) { EnquireLinkSmResp res = PerformEnquireLink(); if (res.Status != CommandStatus.ESME_ROK) { OnError("SendEnquireLink: It has taken more than " + Timeout + " milliseconds to get Enquire Link response"); Disconnect(); return; } } } catch (Exception exception) { OnError("Unhandled Exception", exception); Disconnect(); } }
/// <summary> Constructor for ESME support </summary> public SmppClient(DataCodings defaultEncoding) { DefaultEncoding = defaultEncoding; // Create the socket client _SocketClient = new SocketClient(10485760, 0, this, new SocketClient.MESSAGE_HANDLER(MessageHandler), new SocketClient.CLOSE_HANDLER(CloseHandler), new SocketClient.ERROR_HANDLER(ErrorHandler)); _EnquireLinkTimer = new SynchronousTimer(new SynchronousTimer.SynchronousTimerHandler(SendEnquireLink), null, _EnqInterval); }