Skip to content

Commit

Permalink
add Network error event handler to subscriber example
Browse files Browse the repository at this point in the history
  • Loading branch information
Iwan Budi Kusnanto committed Apr 30, 2012
1 parent c3c0ad0 commit 41bc5c6
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions test/subnya.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,14 @@ def start_nyamuk(server, client_id, topic, username = None, password = None):
handle_publish(ev)
elif ev.type == NC.CMD_SUBACK:
handle_suback(ev)
elif ev.type == EV_NET_ERR:
print "Network Error. Msg = ", ev.msg
sys.exit(-1)
rc = ny.loop()
if rc == NC.ERR_CONN_LOST:
ny.logger.fatal("Connection to server closed")

ny.logger.info("subscriber exited")

if __name__ == '__main__':
if len(sys.argv) != 4:
Expand Down

0 comments on commit 41bc5c6

Please sign in to comment.