日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

在WildFly和OpenShift上的WebSocket聊天

發布時間:2023/12/3 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 在WildFly和OpenShift上的WebSocket聊天 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

聊天是解釋WebSocket的最典型示例之一。 它是一個相當常用的界面,可以很容易地解釋WebSocket的基本概念。 當然,Java EE 7 WebSocket也有一個, 在這里可用 ! 您可以使用以下步驟在WildFly上輕松運行它:

curl -O http://download.jboss.org/wildfly/8.1.0.Final/wildfly-8.1.0.Final.zip unzip wildfly-8.1.0.Final.zip ./wildfly-8.1.0.Final/bin/standalone.sh git clone?https://github.com/javaee-samples/javaee7-samples.git cd javaee7-samples mvn -f websocket/chat/pom.xml wildfly:deploy

然后訪問http:// localhost:8080 / chat / 。

WebSocket的最大優點之一是如何在與HTTP(在本例中為8080)相同的端口上打開套接字。 如果要將此應用程序部署到OpenShift,則可以在端口8000上使用WebSocket進行常規訪問,而在端口8443上進行安全訪問。 下圖對此進行了解釋:

如果要在OpenShift上運行此聊天應用程序,請使用以下步驟:

  • 單擊此處在OpenShift中配置WildFly實例。 將名稱更改為“ chatserver”,并將其他所有名稱更改為默認值。 單擊“創建應用程序”以創建應用程序。
  • 克隆工作空間: git clone ssh://544f08a850044670df00009e@chatserver-milestogo.rhcloud.com/~/git/chatserver.git/
  • 從以下位置編輯“ javaee7-samples / websocket / chat / src / main / webapp / websocket.js”的第一行: var wsUri = "ws://" + document.location.hostname + ":" + document.location.port + document.location.pathname + "chat";

    至:

    var wsUri = "ws://" + document.location.hostname + ":8000" + document.location.pathname + "chat";
  • 創建WAR文件: cd javaee7-samples mvn -f websocket/chat/pom.xml
  • 將生成的WAR文件復制到先前克隆的工作空間中: cd .. cp javaee7-samples/websocket/chat/target/chat.war chatserver/deployments/ROOT.war
  • 刪除現有文件并將WAR文件添加到git存儲庫中: cd chatserver git rm -rf src pom.xml git add deployments/ROOT.war git commit . -m"updating files" git push

    這將輸出顯示為:

    Counting objects: 6, done. Delta compression using up to 8 threads. Compressing objects: 100% (4/4), done. Writing objects: 100% (4/4), 6.88 KiB | 0 bytes/s, done. Total 4 (delta 1), reused 0 (delta 0) remote: Stopping wildfly cart remote: Sending SIGTERM to wildfly:285130 ... remote: Building git ref 'master', commit 05a7978 remote: Preparing build for deployment remote: Deployment id is 14bcec20 remote: Activating deployment remote: Deploying WildFly remote: Starting wildfly cart remote: Found 127.2.87.1:8080 listening port remote: Found 127.2.87.1:9990 listening port remote: /var/lib/openshift/544f08a850044670df00009e/wildfly/standalone/deployments /var/lib/openshift/544f08a850044670df00009e/wildfly remote: /var/lib/openshift/544f08a850044670df00009e/wildfly remote: CLIENT_MESSAGE: Artifacts deployed: ./ROOT.war remote: ------------------------- remote: Git Post-Receive Result: success remote: Activation status: success remote: Deployment completed with status: success To ssh://544f08a850044670df00009e@chatserver-milestogo.rhcloud.com/~/git/chatserver.git/ 454bba9..05a7978? master -> master
  • 現在,您的聊天服務器位于: http : //chatserver-milestogo.rhcloud.com ,看起來像:

    請享用!

    翻譯自: https://www.javacodegeeks.com/2014/10/websocket-chat-on-wildfly-and-openshift.html

    總結

    以上是生活随笔為你收集整理的在WildFly和OpenShift上的WebSocket聊天的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。