public void Dispose() { if (this._handleRef.Handle != IntPtr.Zero) { MessageWrap.DestroyMessage(this._handleRef); this._handleRef = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } }
public IMessageBuilder SetMessageKeys(string keys) { if (string.IsNullOrWhiteSpace(keys)) { MessageWrap.DestroyMessage(this._handleRef); throw new ArgumentException(nameof(keys)); } var result = MessageWrap.SetMessageKeys(this._handleRef, keys); if (result != 0) { MessageWrap.DestroyMessage(this._handleRef); throw new Exception($"set message keys error. cpp sdk return code: {result}"); } return(this); }
public IMessageBuilder SetDelayTimeLevel(int level) { if (level < 0) { MessageWrap.DestroyMessage(this._handleRef); throw new ArgumentOutOfRangeException(nameof(level)); } var result = MessageWrap.SetDelayTimeLevel(this._handleRef, level); if (result != 0) { MessageWrap.DestroyMessage(this._handleRef); throw new Exception($"set delay time level error. cpp sdk return code: {result}"); } return(this); }
public DefaultMessageBuilder(string topic) { if (string.IsNullOrWhiteSpace(topic)) { throw new ArgumentException(nameof(topic)); } var handle = MessageWrap.CreateMessage(topic); this._handleRef = new HandleRef(this, handle); var result = MessageWrap.SetMessageTopic(this._handleRef, topic); if (result != 0) { MessageWrap.DestroyMessage(this._handleRef); throw new Exception($"set message topic error. cpp sdk return code: {result}"); } }
public IMessageBuilder SetByteMessageBody(byte[] body) { if (body == null || body.Length == 0) { MessageWrap.DestroyMessage(this._handleRef); throw new ArgumentException(nameof(body)); } var byteBody = Encoding.UTF8.GetString(body); var result = MessageWrap.SetByteMessageBody(this._handleRef, byteBody, byteBody.Length); if (result != 0) { MessageWrap.DestroyMessage(this._handleRef); throw new Exception($"set message body error. cpp sdk return code: {result}"); } return(this); }
public IMessageBuilder SetMessageProperty(string key, string value) { if (string.IsNullOrWhiteSpace(key)) { MessageWrap.DestroyMessage(this._handleRef); throw new ArgumentException(nameof(key)); } if (string.IsNullOrWhiteSpace(value)) { MessageWrap.DestroyMessage(this._handleRef); throw new ArgumentException(nameof(value)); } var result = MessageWrap.SetMessageProperty(this._handleRef, key, value); if (result != 0) { MessageWrap.DestroyMessage(this._handleRef); throw new Exception($"set message property error. cpp sdk return code: {result}"); } return(this); }