HowtomergepublisherandsubscribercodeinMQTTforESP8266

How to merge publisher and subscriber code in MQTT for ESP8266

http://forum.arduino.cc/index.php?topic=523153.0