@@ -217,7 +217,7 @@ package com.godpaper.mqtt.as3.impl
217
217
*
218
218
*/
219
219
// public function MQTTSocket(host:String=null, port:int=1883, topicname:String=null, clientid:String=null, username:String=null, password:String=null,willRetain:Boolean=true,willQos:Boolean=true,willFlag:Boolean=true,cleanSession:Boolean=true)
220
- public function MQTTSocket (host :String = null , port :int = 1883 ,username :String = null , password :String = null , topicname :String = null , clientid :String = null , will :Boolean = true ,cleanSession :Boolean = true )
220
+ public function MQTTSocket (host :String = null , port :int = 1883 ,username :String = null , password :String = null , topicname :String = null , clientid :String = null , will :Boolean = false ,cleanSession :Boolean = false )
221
221
{
222
222
//parameters store
223
223
if (host)
@@ -483,14 +483,12 @@ package com.godpaper.mqtt.as3.impl
483
483
this . connectMessage= new MQTT_Protocol();
484
484
var bytes : ByteArray = new ByteArray ();
485
485
bytes . writeByte (0x00 ); //0
486
- bytes . writeByte (0x06 ); //6
486
+ bytes . writeByte (0x04 ); //6
487
487
bytes . writeByte (0x4d ); //M
488
488
bytes . writeByte (0x51 ); //Q
489
- bytes . writeByte (0x49 ); //I
490
- bytes . writeByte (0x73 ); //S
491
- bytes . writeByte (0x64 ); //D
492
- bytes . writeByte (0x70 ); //P
493
- bytes . writeByte (0x03 ); //Protocol version = 3
489
+ bytes . writeByte (0x54 ); //T
490
+ bytes . writeByte (0x54 ); //T
491
+ bytes . writeByte (0x04 ); //Protocol version = 3
494
492
//Connect flags
495
493
var type : int = 0 ;
496
494
if (cleanSession)
@@ -707,20 +705,20 @@ package com.godpaper.mqtt.as3.impl
707
705
//Variable header
708
706
//Payload
709
707
//Actions
710
- var varHead: ByteArray = packet. readMessageValue();
708
+ var varHead: ByteArray = packet. readMessageValue();
711
709
var length : uint = (varHead. readUnsignedByte () << 8 ) + varHead. readUnsignedByte ();
712
710
var topicName: String = varHead. readMultiByte (length , "utf" );
713
711
if ( packet. readQoS() ){
714
712
var messageId : uint = (varHead. readUnsignedByte () << 8 ) + varHead. readUnsignedByte ();
715
713
LOG . info ("Publish Message ID {0}" , messageId );
716
714
}
717
715
var payLoad: ByteArray = packet. readPayLoad();
718
- length = (payLoad. readUnsignedByte () << 8 ) + payLoad. readUnsignedByte ();
719
- if ( length > payLoad. length ){
720
- length = payLoad. length ;
721
- payLoad. position = 0 ;
722
- }
723
- var topicContent: String = payLoad. readMultiByte (length , "utf" );
716
+ // length = (payLoad.readUnsignedByte() << 8) + payLoad.readUnsignedByte();
717
+ // if( length > payLoad.length ){
718
+ // length = payLoad.length;
719
+ // payLoad.position = 0;
720
+ // }
721
+ var topicContent: String = payLoad. readMultiByte (payLoad . length , "utf-8 " );
724
722
725
723
LOG . info ("Publish TopicName {0}" , topicName);
726
724
LOG . info ("Publish TopicContent {0}" , topicContent);
0 commit comments