如题所述
ããMQTTæ¯ä¸ä¸ªè½»é级çæ¶æ¯åå¸/订é åè®®ï¼å®æ¯å®ç°åºäºææºå®¢æ·ç«¯çæ¶æ¯æ¨éæå¡å¨ççæ³è§£å³æ¹æ¡ã
ããæ们å¯ä»¥ä»è¿éä¸è½½è¯¥é¡¹ç®çå®ä¾ä»£ç ï¼å¹¶ä¸å¯ä»¥æ¾å°ä¸ä¸ªéç¨PHP书åçæå¡å¨ç«¯å®ç°ã
ããæ¶æå¦ä¸æ示ï¼
ããwmqtt.jar æ¯IBMæä¾çMQTTåè®®çå®ç°ãä½ å¯ä»¥ä»å¦ä¸ç«ç¹ä¸è½½å®ãä½ å¯ä»¥å°è¯¥jarå å å ¥ä½ èªå·±çAndroidåºç¨ç¨åºä¸ã
ããReally Small Message Broker (RSMB) ï¼ä»æ¯ä¸ä¸ªç®åçMQTT代çï¼åæ ·ç±IBMæä¾ã缺çæå¼1883端å£ï¼åºç¨ç¨åºå½ä¸ï¼å®è´è´£æ¥æ¶æ¥èªæå¡å¨çæ¶æ¯å¹¶å°å ¶è½¬åç»æå®ç移å¨è®¾å¤ã
ããSAMæ¯ä¸ä¸ªé对MQTTåçPHPåºãä½ å¯ä»¥ä»è¿ä¸ªä¸è½½å®.
ããsend_mqtt.phpæ¯ä¸ä¸ªéè¿POSTæ¥æ¶æ¶æ¯å¹¶ä¸éè¿SAMå°æ¶æ¯åéç»RSMBçPHPèæ¬ã
ããå®ä¾ä»£ç ï¼
ããØ éç¨XMPPåè®®å®ç°Androidæ¨é
ããè¿æ¯æå¨é¡¹ç®ä¸éç¨çæ¹æ¡ãäºå®ä¸Googleå®æ¹çC2DMæå¡å¨åºå±ä¹æ¯éç¨XMPPåè®®è¿è¡çå°è£ ã
ããXMPP(å¯æ©å±é讯å表示åè®®)æ¯åºäºå¯æ©å±æ è®°è¯è¨ï¼XMLï¼çåè®®ï¼å®ç¨äºå³æ¶æ¶æ¯ï¼IMï¼ä»¥åå¨çº¿æ¢æµãè¿ä¸ªåè®®å¯è½æç»å 许å ç¹ç½ç¨æ·åå ç¹ç½ä¸çå ¶ä»ä»»ä½äººåéå³æ¶æ¶æ¯ã
ããandroidpnæ¯ä¸ä¸ªåºäºXMPPåè®®çjavaå¼æºAndroid push notificationå®ç°ãå®å å«äºå®æ´ç客æ·ç«¯åæå¡å¨ç«¯ãç»è¿æºä»£ç ç 究æåç°ï¼è¯¥æå¡å¨ç«¯åºæ¬æ¯å¨å¦å¤ä¸ä¸ªå¼æºå·¥ç¨openfireåºç¡ä¸ä¿®æ¹å®ç°çï¼ä¸è¿æ¯è¾éé·çæ¯androidpnçææ¡£æ¯ç±é©è¯åçï¼æ以æ´ä¸ªç 究è¿ç¨åºæ¬é½æ¯è¯»æºç ãå®çå®ç°ç¤ºæå¾å¦ä¸ï¼
ããandroidpn客æ·ç«¯éè¦ç¨å°ä¸ä¸ªåºäºjavaçå¼æºXMPPåè®®å asmackï¼è¿ä¸ªå åæ ·ä¹æ¯åºäºopenfireä¸çå¦å¤ä¸ä¸ªå¼æºé¡¹ç®smackï¼ä¸è¿æ们ä¸éè¦èªå·±ç¼è¯ï¼å¯ä»¥ç´æ¥æandroidpn客æ·ç«¯éé¢çasmack.jaræ¿æ¥ä½¿ç¨ã客æ·ç«¯å©ç¨asmackä¸æä¾çXMPPConnectionç±»ä¸æå¡å¨å»ºç«æä¹ è¿æ¥ï¼å¹¶éè¿è¯¥è¿æ¥è¿è¡ç¨æ·æ³¨ååç»å½è®¤è¯ï¼åæ ·ä¹æ¯éè¿è¿æ¡è¿æ¥ï¼æ¥æ¶æå¡å¨åéçéç¥ã
ããandroidpnæå¡å¨ç«¯ä¹æ¯javaè¯è¨å®ç°çï¼åºäºopenfireå¼æºå·¥ç¨ï¼ä¸è¿å®çWebé¨åéç¨çæ¯springæ¡æ¶ï¼è¿ä¸ç¹ä¸openfireæ¯ä¸åçãAndroidpnæå¡å¨å å«ä¸¤ä¸ªé¨åï¼ä¸ä¸ªæ¯ä¾¦å¬å¨5222端å£ä¸çXMPPæå¡ï¼è´è´£ä¸å®¢æ·ç«¯çXMPPConnectionç±»è¿è¡éä¿¡ï¼ä½ç¨æ¯ç¨æ·æ³¨åå身份认è¯ï¼å¹¶åéæ¨ééç¥æ¶æ¯ãå¦å¤ä¸é¨åæ¯Webæå¡å¨ï¼éç¨ä¸ä¸ªè½»é级çHTTPæå¡å¨ï¼è´è´£æ¥æ¶ç¨æ·çWeb请æ±ãæå¡å¨æ¶æå¦ä¸ï¼
ããæä¸å±å å«å个ç»æé¨åï¼åå«æ¯SessionManagerï¼Auth Managerï¼PresenceManager以åNotification ManagerãSessionManagerè´è´£ç®¡ç客æ·ç«¯ä¸æå¡å¨ä¹é´çä¼è¯ï¼Auth Managerè´è´£å®¢æ·ç«¯ç¨æ·è®¤è¯ç®¡çï¼Presence Managerè´è´£ç®¡ç客æ·ç«¯ç¨æ·çç»å½ç¶æï¼NotificationManagerè´è´£å®ç°æå¡å¨å客æ·ç«¯æ¨éæ¶æ¯åè½ã
ããæå¡å¨ç«¯çé¢å¦ä¸ï¼åå«å¯¹åºäºä¸è¿°çå 个åè½æ¨¡åï¼
ããåé以åï¼æ们å¯ä»¥å¨ææºç«¯çå°æ¥æ¶çæ¶æ¯ï¼
ãã