Mercurial > prosody-modules
comparison mod_pubsub_mqtt/mqtt.lib.lua @ 1343:7dbde05b48a9
all the things: Remove trailing whitespace
| author | Florian Zeitz <florob@babelmonkeys.de> |
|---|---|
| date | Tue, 11 Mar 2014 18:44:01 +0100 |
| parents | e0d97eb52ab8 |
| children | d2a84e6aed2b |
comparison
equal
deleted
inserted
replaced
| 1342:0ae065453dc9 | 1343:7dbde05b48a9 |
|---|---|
| 42 local header = self:read_bytes(1):byte(); | 42 local header = self:read_bytes(1):byte(); |
| 43 packet.type = packet_type_codes[bit.rshift(bit.band(header, 0xf0), 4)]; | 43 packet.type = packet_type_codes[bit.rshift(bit.band(header, 0xf0), 4)]; |
| 44 packet.dup = bit.band(header, 0x08) == 0x08; | 44 packet.dup = bit.band(header, 0x08) == 0x08; |
| 45 packet.qos = bit.rshift(bit.band(header, 0x06), 1); | 45 packet.qos = bit.rshift(bit.band(header, 0x06), 1); |
| 46 packet.retain = bit.band(header, 0x01) == 0x01; | 46 packet.retain = bit.band(header, 0x01) == 0x01; |
| 47 | 47 |
| 48 -- Get length | 48 -- Get length |
| 49 local length, multiplier = 0, 1; | 49 local length, multiplier = 0, 1; |
| 50 repeat | 50 repeat |
| 51 local digit = self:read_bytes(1):byte(); | 51 local digit = self:read_bytes(1):byte(); |
| 52 length = length + bit.band(digit, 0x7f)*multiplier; | 52 length = length + bit.band(digit, 0x7f)*multiplier; |
| 127 type_num = i; | 127 type_num = i; |
| 128 break; | 128 break; |
| 129 end | 129 end |
| 130 end | 130 end |
| 131 local header = string.char(bit.lshift(type_num, 4)); | 131 local header = string.char(bit.lshift(type_num, 4)); |
| 132 | 132 |
| 133 if packet.type == "publish" then | 133 if packet.type == "publish" then |
| 134 local topic = packet.topic or ""; | 134 local topic = packet.topic or ""; |
| 135 packet.data = string.char(bit.band(#topic, 0xff00), bit.band(#topic, 0x00ff))..topic..packet.data; | 135 packet.data = string.char(bit.band(#topic, 0xff00), bit.band(#topic, 0x00ff))..topic..packet.data; |
| 136 elseif packet.type == "suback" then | 136 elseif packet.type == "suback" then |
| 137 local t = {}; | 137 local t = {}; |
| 138 for _, topic in ipairs(packet.topics) do | 138 for _, topic in ipairs(packet.topics) do |
| 139 table.insert(t, string.char(bit.band(#topic, 0xff00), bit.band(#topic, 0x00ff))..topic.."\000"); | 139 table.insert(t, string.char(bit.band(#topic, 0xff00), bit.band(#topic, 0x00ff))..topic.."\000"); |
| 140 end | 140 end |
| 141 packet.data = table.concat(t); | 141 packet.data = table.concat(t); |
| 142 end | 142 end |
| 143 | 143 |
| 144 -- Get length | 144 -- Get length |
| 145 local length = #(packet.data or ""); | 145 local length = #(packet.data or ""); |
| 146 repeat | 146 repeat |
| 147 local digit = length%128; | 147 local digit = length%128; |
| 148 length = math.floor(length/128); | 148 length = math.floor(length/128); |
| 149 if length > 0 then | 149 if length > 0 then |
| 150 digit = bit.bor(digit, 0x80); | 150 digit = bit.bor(digit, 0x80); |
| 151 end | 151 end |
| 152 header = header..string.char(digit); -- FIXME: ... | 152 header = header..string.char(digit); -- FIXME: ... |
| 153 until length <= 0; | 153 until length <= 0; |
| 154 | 154 |
| 155 return header..(packet.data or ""); | 155 return header..(packet.data or ""); |
| 156 end | 156 end |
| 157 | 157 |
| 158 return { | 158 return { |
| 159 new_stream = new_stream; | 159 new_stream = new_stream; |
