Class: Mosquitto::Message
- Inherits:
-
Object
- Object
- Mosquitto::Message
- Defined in:
- ext/mosquitto/message.c
Instance Method Summary collapse
-
#length ⇒ Integer
The length of the message payload.
-
#mid ⇒ Integer
Message identifier for this message.
-
#qos ⇒ Integer
Quality of Service used for the message.
-
#retain? ⇒ Boolean
Set to true if this message was flagged to retain.
-
#to_s ⇒ String
Coerces the Mosquitto::Message payload to a Ruby string.
-
#topic ⇒ String
Topic this message was published on.
Instance Method Details
#length ⇒ Integer
The length of the message payload
102 103 104 105 106 107 108 |
# File 'ext/mosquitto/message.c', line 102 static VALUE (VALUE obj) { struct *msg; MosquittoGetMessage(obj); msg = ->msg; return INT2NUM(msg->payloadlen); } |
#mid ⇒ Integer
Message identifier for this message. Note that although the MQTT protocol doesn’t use message ids for messages with QoS=0, libmosquitto assigns them message ids so they can be tracked with this parameter.
45 46 47 48 49 50 51 |
# File 'ext/mosquitto/message.c', line 45 static VALUE (VALUE obj) { struct *msg; MosquittoGetMessage(obj); msg = ->msg; return INT2NUM(msg->mid); } |
#qos ⇒ Integer
Quality of Service used for the message
125 126 127 128 129 130 131 |
# File 'ext/mosquitto/message.c', line 125 static VALUE (VALUE obj) { struct *msg; MosquittoGetMessage(obj); msg = ->msg; return INT2NUM(msg->qos); } |
#retain? ⇒ Boolean
Set to true if this message was flagged to retain.
144 145 146 147 148 149 150 |
# File 'ext/mosquitto/message.c', line 144 static VALUE (VALUE obj) { struct *msg; MosquittoGetMessage(obj); msg = ->msg; return (msg->retain == true) ? Qtrue : Qfalse; } |
#to_s ⇒ String
Coerces the Mosquitto::Message payload to a Ruby string.
83 84 85 86 87 88 89 |
# File 'ext/mosquitto/message.c', line 83 static VALUE (VALUE obj) { struct *msg; MosquittoGetMessage(obj); msg = ->msg; return MosquittoEncode(rb_str_new(msg->payload, msg->payloadlen)); } |
#topic ⇒ String
Topic this message was published on.
64 65 66 67 68 69 70 |
# File 'ext/mosquitto/message.c', line 64 static VALUE (VALUE obj) { struct *msg; MosquittoGetMessage(obj); msg = ->msg; return MosquittoEncode(rb_str_new2(msg->topic)); } |