源碼搭建Openfire 4.3.2 note

源碼部署Openfire 4.3.2 troubleshooting:
    1:war-maven-plugin 2.6一直下載不成功,配置文件改成了3.2.0
    2:根據源碼裏documentation的source-build.html文件步驟執行
    3:執行mvn test的時候拋了一個關於surefire plugin的error,需要maven 3.6以上的版本
    
Openfire 消息處理的入口:ConnectionHandler.messageReceived()方法。
ConnectionHandler實現的mina框架提供的api,用來處理IO。

Openfire 4.3.2 之 Presence
   Scenario:用戶A改變自己的presence, 用戶B希望收到用戶A presence的推送
   Troubleshooting
        當用戶A send presence to openfire的時候,會經過PresenceUpdateHandler.broadcastUpdate(Presence update),
        然後由Roster來廣播presence。
        
        Roster中一段代碼:
        item.getSubStatus() == RosterItem.SUB_BOTH || item.getSubStatus() == RosterItem.SUB_FROM
        presence只會廣播給訂閱了用戶A(presence sender)的用戶。查看ofRoster表,sub字段都沒數據,所以其他用戶收不到用戶A的presence包。
        RosterItem -》SubType各個枚舉項意思,refer to (
                                                doc url: https://xmpp.org/extensions/xep-0162.html 
                                                1.2 Overview of subscription states
                                            )
    Solutions
        - Openfire官網提供了subscription插件,下載後copy到distribution\target\distribution-base\plugins文件夾下,
        啓動openfire的時候會自動加載該插件。並在admin console -》Subscription Service Settings中設置accept subscription requests。
        用戶希望收到誰的presence推送,可以發送type=subscribe的presence包到openfire,openfire會自動同意。被訂閱的用戶改變presence時,
        訂閱方RosterListener就可收到該推送。

Openfire 4.3.2 之 Plugins
    Openfire custom plugin development:(視項目實際結構而定)
        Steps
            - 創建plugins module的子module
            - 子module的pom.xml文件中build標籤中添加maven-assembly-plugin
            - 修改openfire-plugin-assembly-descriptor module的openfire-plugin-assembly.xml文件。
             (按照自己module的目錄結構修改配置,保證生成的jar包的目錄結構和官網要求的plugin的目錄結構保持一致)
            - 打包後copy到distribution\target\distribution-base\plugins
        Note: 如果還沒有配置openfire,啓動時只會先加載admin plugin,配置結束後纔會加載其他plugin。
          如果已配置openfire,啓動的時候會加載所有插件。
        Doc refer to:
            https://www.jianshu.com/p/869cb5688cac
            http://download.igniterealtime.org/openfire/docs/latest/documentation/plugin-dev-guide.html
    自動將plugin打包並copy到openfireHome\plugins:(視項目實際結構而定)
        - parent module的pom.xml添加自定義插件的依賴。
        - distribution module -》pom.xml -》maven-dependency-plugin 添加自定義插件的<artifactItem>,格式參照search
          artifactItem
        - 執行parent module的package task。
 
 
創建plugin子module:
右鍵項目-》new module -》 Next
  Add as module to -》org.igniterealtime.openfire:plugins
  Parent -》 org.igniterealtime.openfire:plugins
  GroupId -》org.igniterealtime.openfire.plugins
  ArtifactId -》 openfire-plugin-archive
Next:
  Module name:openfire-plugin-archive
  Content root: D:\IDEAProjects\Openfire-4.3.2\plugins\openfire-plugin-archive
  Module file location:D:\IDEAProjects\Openfire-4.3.2\plugins\openfire-plugin-archive
Finish
 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章