public void publish(String topicName,int qos,byte[] payload) throws Throwable {
  while (state != FINISH) {
switch (state) {
case BEGIN:
      MqttConnector con=new MqttConnector();
    con.doConnect();
  break;
case CONNECTED:
Publisher pub=new Publisher();
pub.doPublish(topicName,qos,payload);
break;
case PUBLISHED:
state=DISCONNECT;
donext=true;
break;
case DISCONNECT:
Disconnector disc=new Disconnector();
disc.doDisconnect();
break;
case ERROR:
throw ex;
case DISCONNECTED:
state=FINISH;
donext=true;
break;
}
waitForStateChange(10000);
}
}

public void publish ( String topicName , int qos , byte [ ] payload ) throws Throwable { while ( state != FINISH ) { switch ( state ) { case BEGIN : MqttConnector con = new MqttConnector ( ) ; con . doConnect ( ) ; break ; case CONNECTED : Publisher pub = new Publisher ( ) ; pub . doPublish ( topicName , qos , payload ) ; break ; case PUBLISHED : state = DISCONNECT ; donext = true ; break ; case DISCONNECT : Disconnector disc = new Disconnector ( ) ; disc . doDisconnect ( ) ; break ; case ERROR : throw ex ; case DISCONNECTED : state = FINISH ; donext = true ; break ; } waitForStateChange ( 10000 ) ; } }
publish / send a message to an mqtt server
