在WildFly和OpenShift上的WebSocket聊天
聊天是解釋W(xué)ebSocket的最典型示例之一。 它是一個(gè)相當(dāng)常用的界面,可以很容易地解釋W(xué)ebSocket的基本概念。 當(dāng)然,Java EE 7 WebSocket也有一個(gè), 在這里可用 ! 您可以使用以下步驟在WildFly上輕松運(yùn)行它:
然后訪問http:// localhost:8080 / chat / 。
WebSocket的最大優(yōu)點(diǎn)之一是如何在與HTTP(在本例中為8080)相同的端口上打開套接字。 如果要將此應(yīng)用程序部署到OpenShift,則可以在端口8000上使用WebSocket進(jìn)行常規(guī)訪問,而在端口8443上進(jìn)行安全訪問。 下圖對(duì)此進(jìn)行了解釋:
如果要在OpenShift上運(yùn)行此聊天應(yīng)用程序,請(qǐng)使用以下步驟:
至:
var wsUri = "ws://" + document.location.hostname + ":8000" + document.location.pathname + "chat";這將輸出顯示為:
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現(xiàn)在,您的聊天服務(wù)器位于: http : //chatserver-milestogo.rhcloud.com ,看起來像:
請(qǐng)享用!
翻譯自: https://www.javacodegeeks.com/2014/10/websocket-chat-on-wildfly-and-openshift.html
總結(jié)
以上是生活随笔為你收集整理的在WildFly和OpenShift上的WebSocket聊天的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: PrimeFaces Mobile入门
- 下一篇: 安卓祖玛游戏(安卓祖玛)