GCM alternative for local networks or sending messages to device IP

ⅰ亾dé卋堺 提交于 2020-01-03 16:58:13

问题


I want to send notifications to some devices connected to my local network. First alternative was GCM but this implies sending a message to Google server and then Google server sends the message to devices. What if currently my local network is not providing internet?

If there is no such alternative like this, is there a way to send a message through a TCP package directly to the device?


回答1:


You should take a look at MQTT. There is also a Java library that is compatible with Android; the Eclipse Paho Client. In very simplistic terms, MQTT an asynchronous publish/subscribe mechanism that is well suited for what you want. It runs on top of TCP/IP.. You will need to use a MQTT broker on the server side (i.e. mosquitto (mosquitto.org) or RSMB (Really Small Message Broaker), etc)

If you are interested, I created a simple project that allows you to connect to a Raspberry Pi and turn the lights of your house on and off using and Android device. Here is the git



来源:https://stackoverflow.com/questions/17504761/gcm-alternative-for-local-networks-or-sending-messages-to-device-ip

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!