mqtt-client回调方法简介

本文介绍了使用Fusesource mqtt-client时的三种API:Blocking API、Future based API和Callback/Continuation。重点讲解了Callback/Continuation,包括如何获取回调连接,以及connect、listener、subscribe、publish和disconnect等方法的使用。特别强调了在回调方法中避免阻塞操作以防止执行顺序错误。
摘要由CSDN通过智能技术生成

使用Fusesource mqtt-client作为mqtt客户包使用,其总共提供了三种API:

1.Blocking API(阻塞式API)

2.Future based API

3.Callback/Continuation(阻塞式API)

其中第三种Callback阻塞式是前两种的基础,可以通过前两种的源码中证明:

public FutureConnection(CallbackConnection next){
        receiveFutures = new LinkedList();
        receivedFrames = new LinkedList();
        this.next = next;
        this.next.listener(new Listener() {

            public void onConnected()
            {
                connected = true;
            }

            public void onDisconnected()
            {
                connected = false;
            }

            pub
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值