Codec changes
diff --git a/src/Mqtt_v3.1.1_EncDec.cc b/src/Mqtt_v3.1.1_EncDec.cc
index ea421ce..866a212 100644
--- a/src/Mqtt_v3.1.1_EncDec.cc
+++ b/src/Mqtt_v3.1.1_EncDec.cc
@@ -48,7 +48,7 @@
unsigned char encodedByte;
int tmpLength;
unsigned char flag;
-
+
//get packet length
do{
if(str.lengthof() < position){
@@ -65,7 +65,7 @@
position++;
prePosition++;
}while((encodedByte & 128) != 0);
-
+
switch(packetType){
case 1:
msg.msg().connect__msg().header().flags() = BITSTRING(4, &bitstr);
@@ -103,7 +103,7 @@
msg.raw__message() = str;
return 1;
}
- msg.msg().connect__msg().payload().client__identifier()().decode_utf8(tmpLength, &str_ptr[position+2]);
+ msg.msg().connect__msg().payload().client__identifier().decode_utf8(tmpLength, &str_ptr[position+2]);
position += 2+tmpLength;
if(msg.msg().connect__msg().flags().will__flag()[0].get_bit() == 1){
if(str.lengthof() < position+2){
@@ -117,7 +117,7 @@
}
msg.msg().connect__msg().payload().will__topic()().decode_utf8(tmpLength, &str_ptr[position+2]);
position += 2+tmpLength;
-
+
tmpLength = decodeInteger(str_ptr, position, 2);
if(str.lengthof() < position+2+tmpLength){
msg.raw__message() = str;
@@ -385,7 +385,7 @@
default:
break;
}
-
+
switch(msg.msg().get_selection()){
case MQTT__v3__1__1__ReqResp::ALT_connect__msg:
chr = 1 << 4;
@@ -431,10 +431,8 @@
return 1;
}
//payload
- if(msg.msg().connect__msg().payload().client__identifier().ispresent()){
- if(encodeUtf8(stream, msg.msg().connect__msg().payload().client__identifier()(), length) != 0){
- return 1;
- }
+ if(encodeUtf8(stream, msg.msg().connect__msg().payload().client__identifier(), length) != 0){
+ return 1;
}
if(msg.msg().connect__msg().payload().will__topic().ispresent()){
if(encodeUtf8(stream, msg.msg().connect__msg().payload().will__topic()(), length) != 0){
@@ -527,7 +525,7 @@
}else{
return 1;
}
-
+
//variable header
if(encodePacketIdentifier(stream, (int) msg.msg().pubrec().packet__identifier(), length) != 0){
return 1;
@@ -692,7 +690,7 @@
const unsigned char lookup[16] = {
0x0, 0x8, 0x4, 0xc, 0x2, 0xa, 0x6, 0xe,
0x1, 0x9, 0x5, 0xd, 0x3, 0xb, 0x7, 0xf};
-
+
chr = (const unsigned char*) bits;
return lookup[chr[0]];
}