实例介绍
IBM的MQTT给了一个PHP的服务端代码,在网上找了一个JAVA实现服务端代码的例子,调通了。如果想做这个例子需要自己用电脑建一个wifi,手机连上这个wifi,代码中要改几个个地方 1 android服务里有几个MQTT_HOST是ip地址改成自己wifi的ip; 2 服务端的publish方法是用来发送的,第一个参数是客户端id clientId,要改成自己在手机客户端设定的名字,前面还有个域,比如mqttClient.publish("tokudu/"+clientId, message.getBytes(), 0, false); 我的clientId是sly。其他的大家就自己研究
【实例截图】
【核心代码】
shily3_7250815
└── 商品手机推送
├── AndroidPushNotificationsDemo
│ ├── 16x16_loading.gif
│ ├── AndroidManifest.xml
│ ├── bin
│ │ ├── AndroidManifest.xml
│ │ ├── classes
│ │ │ ├── com
│ │ │ │ └── tokudu
│ │ │ │ └── demo
│ │ │ │ ├── BuildConfig.class
│ │ │ │ ├── ConnectionLog.class
│ │ │ │ ├── ConnectServerTask$1.class
│ │ │ │ ├── ConnectServerTask$ConnectionCallBack.class
│ │ │ │ ├── ConnectServerTask$MQTTConnection.class
│ │ │ │ ├── ConnectServerTask.class
│ │ │ │ ├── PushActivity$1.class
│ │ │ │ ├── PushActivity$2.class
│ │ │ │ ├── PushActivity.class
│ │ │ │ ├── PushService$1.class
│ │ │ │ ├── PushService$MQTTConnection.class
│ │ │ │ ├── PushService2$1.class
│ │ │ │ ├── PushService2$ConnectionTask.class
│ │ │ │ ├── PushService2$MQTTConnection.class
│ │ │ │ ├── PushService2.class
│ │ │ │ ├── PushService.class
│ │ │ │ ├── R$attr.class
│ │ │ │ ├── R$color.class
│ │ │ │ ├── R$drawable.class
│ │ │ │ ├── R$id.class
│ │ │ │ ├── R$layout.class
│ │ │ │ ├── R$string.class
│ │ │ │ └── R.class
│ │ │ └── org
│ │ │ └── yooh
│ │ │ └── util
│ │ │ └── Marquee.class
│ │ ├── classes.dex
│ │ ├── dexedLibs
│ │ │ ├── annotations-c1524c5d4fef3b4d3cf8a79595fab927.jar
│ │ │ ├── ezmorph-0.9.1-ce7a83a1caab35997e93c49adaeb7e46.jar
│ │ │ ├── json-lib-0.9-5e34e11397998cef48faf036bb2eb166.jar
│ │ │ └── wmqtt-ad5f81971332fcd51cb9e014a0919cbf.jar
│ │ ├── jarlist.cache
│ │ ├── PushActivity.apk
│ │ ├── res
│ │ │ ├── drawable
│ │ │ │ ├── icon.png
│ │ │ │ └── logo.png
│ │ │ ├── drawable-hdpi
│ │ │ │ └── icon.png
│ │ │ ├── drawable-ldpi
│ │ │ │ └── icon.png
│ │ │ ├── drawable-mdpi
│ │ │ │ └── icon.png
│ │ │ └── drawable-xhdpi
│ │ │ └── icon.png
│ │ └── resources.ap_
│ ├── etc
│ │ └── config.php
│ ├── gen
│ │ └── com
│ │ └── tokudu
│ │ └── demo
│ │ ├── BuildConfig.java
│ │ └── R.java
│ ├── hs_err_pid10408.log
│ ├── hs_err_pid11112.log
│ ├── hs_err_pid3120.log
│ ├── hs_err_pid3884.log
│ ├── index.php
│ ├── jquery.js
│ ├── jquery.label_over.js
│ ├── lib
│ │ ├── MQTT
│ │ │ └── sam_mqtt.php
│ │ ├── php_sam.php
│ │ ├── sam_factory_mqtt.php
│ │ └── sam_factory_xms.php
│ ├── libs
│ │ ├── ezmorph-0.9.1.jar
│ │ ├── json-lib-0.9.jar
│ │ └── wmqtt.jar
│ ├── project.properties
│ ├── README
│ ├── res
│ │ ├── drawable
│ │ │ ├── clothe1.jpg
│ │ │ ├── clothe2.jpg
│ │ │ ├── clothe3.jpg
│ │ │ ├── icon.png
│ │ │ ├── logo.png
│ │ │ ├── phone1.jpg
│ │ │ ├── phone2.jpg
│ │ │ ├── phone3.jpg
│ │ │ ├── shoe1.jpg
│ │ │ ├── shoe2.jpg
│ │ │ ├── shoe3.jpg
│ │ │ └── shoe4.jpg
│ │ ├── drawable-hdpi
│ │ │ └── icon.png
│ │ ├── drawable-ldpi
│ │ │ └── icon.png
│ │ ├── drawable-mdpi
│ │ │ └── icon.png
│ │ ├── drawable-xhdpi
│ │ │ └── icon.png
│ │ ├── layout
│ │ │ ├── gallery.xml
│ │ │ ├── image.xml
│ │ │ └── main.xml
│ │ └── values
│ │ ├── colors.xml
│ │ └── strings.xml
│ ├── send_mqtt.php
│ └── src
│ ├── com
│ │ └── tokudu
│ │ └── demo
│ │ ├── ConnectionLog.java
│ │ ├── ConnectServerTask.java
│ │ ├── PushActivity.java
│ │ ├── PushService2.java
│ │ └── PushService.java
│ └── org
│ └── yooh
│ └── util
│ └── Marquee.java
├── MqttBroker
│ ├── bin
│ │ └── com
│ │ └── asiainfo
│ │ └── push
│ │ ├── MqttBroker$SimpleCallbackHandler.class
│ │ ├── MqttBroker.class
│ │ └── TestTimerTask.class
│ ├── lib
│ │ ├── commons-logging-1.1.jar
│ │ ├── ezmorph-0.9.1.jar
│ │ ├── json-lib-0.9.jar
│ │ └── wmqtt.jar
│ └── src
│ └── com
│ └── asiainfo
│ └── push
│ ├── MqttBroker.java
│ └── TestTimerTask.java
└── rsmb
├── doc
│ ├── gettingstarted.htm
│ └── html
│ ├── annotated.html
│ ├── async.html
│ ├── classes.html
│ ├── doxygen.css
│ ├── doxygen.png
│ ├── files.html
│ ├── functions.html
│ ├── functions_vars.html
│ ├── globals_defs.html
│ ├── globals_func.html
│ ├── globals.html
│ ├── globals_type.html
│ ├── index.html
│ ├── _m_q_t_t_client_8h.html
│ ├── _m_q_t_t_client_8h_source.html
│ ├── _m_q_t_t_client_persistence_8h.html
│ ├── _m_q_t_t_client_persistence_8h_source.html
│ ├── pages.html
│ ├── pubasync.html
│ ├── pubsync.html
│ ├── qos.html
│ ├── struct_m_q_t_t_client__connect_options.html
│ ├── struct_m_q_t_t_client__message.html
│ ├── struct_m_q_t_t_client__persistence.html
│ ├── struct_m_q_t_t_client__will_options.html
│ ├── subasync.html
│ ├── tab_b.gif
│ ├── tab_l.gif
│ ├── tab_r.gif
│ ├── tabs.css
│ └── wildcard.html
├── include
│ ├── MQTTClient.h
│ └── MQTTClientPersistence.h
├── license
│ ├── Lic_cs.txt
│ ├── Lic_de.txt
│ ├── Lic_el.txt
│ ├── Lic_en.txt
│ ├── Lic_es.txt
│ ├── Lic_fr.txt
│ ├── Lic_it.txt
│ ├── Lic_ja.txt
│ ├── Lic_ko.txt
│ ├── Lic_lt.txt
│ ├── Lic_pl.txt
│ ├── Lic_pt.txt
│ ├── Lic_ru.txt
│ ├── Lic_sl.txt
│ ├── Lic_tr.txt
│ ├── Lic_zh_TW.txt
│ └── Lic_zh.txt
├── linux_ARM_glibc
│ ├── broker
│ ├── libmqttv3c.so
│ ├── stdinpub
│ └── stdoutsub
├── linux_ARM_uclibc
│ ├── broker
│ ├── libmqttv3c.so
│ ├── stdinpub
│ └── stdoutsub
├── linux_ia32
│ ├── 1885.cfg
│ ├── a.out
│ ├── broker
│ ├── broker.cfg
│ ├── libmqttv3c.so
│ ├── Messages.1.2.0.1
│ ├── mstdoutsub.c
│ ├── stdinpub
│ ├── stdoutsub
│ └── Thread.h
├── linux_ia64
│ ├── broker
│ ├── libmqttv3c.so
│ ├── stdinpub
│ └── stdoutsub
├── mac
│ ├── broker
│ ├── libmqttv3c.dylib
│ ├── stdinpub
│ └── stdoutsub
├── messages
│ └── Messages.1.2.0
├── README.htm
├── slug
│ ├── broker
│ ├── libmqttv3c.so
│ ├── stdinpub
│ └── stdoutsub
├── windows
│ ├── broker.exe
│ ├── mqttv3c.dll
│ ├── mqttv3c.lib
│ ├── send_mqtt
│ │ └── send_mqtt
│ │ ├── 16x16_loading.gif
│ │ ├── etc
│ │ │ ├── config.php
│ │ │ └── config.php.bak
│ │ ├── index.php
│ │ ├── jquery.js
│ │ ├── jquery.label_over.js
│ │ ├── lib
│ │ │ ├── MQTT
│ │ │ │ └── sam_mqtt.php
│ │ │ ├── php_sam.php
│ │ │ ├── sam_factory_mqtt.php
│ │ │ └── sam_factory_xms.php
│ │ ├── README
│ │ └── send_mqtt.php
│ ├── send_mqtt.zip
│ ├── stdinpub.exe
│ └── stdoutsub.exe
└── zlinux
├── broker
├── libmqttv3c.so
├── stdinpub
└── stdoutsub
69 directories, 202 files
标签:
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
网友评论
我要评论