forked from ArtGeekTech/health-monitor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
before adding auth & api gateway services
- Loading branch information
guxiong
committed
Aug 13, 2019
1 parent
49b5fad
commit 7595dde
Showing
12 changed files
with
125 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 42 additions & 41 deletions
83
data-dashboard/src/main/resources/static/WebSocketController.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,49 @@ | ||
class WebSocketController { | ||
constructor() { | ||
this._onConnected = this._onConnected.bind(this); | ||
} | ||
_onConnected(frame) { | ||
|
||
constructor() { | ||
this._onConnected = this._onConnected.bind(this); | ||
} | ||
|
||
_onConnected(frame) { | ||
this.setConnected(true); | ||
console.log('Connected: ' + frame); | ||
this.stompClient.subscribe('/topic/realtime', this.showMessage); | ||
} | ||
setConnected(connected) { | ||
document.getElementById('connect').disabled = connected; | ||
document.getElementById('disconnect').disabled = !connected; | ||
document.getElementById('realtime').style.visibility = connected ? 'visible' : 'hidden'; | ||
document.getElementById('response').innerHTML = ''; | ||
} | ||
connect() { | ||
var socket = new SockJS('/websocket-app'); | ||
this.stompClient = Stomp.over(socket); | ||
this.stompClient.connect({}, this._onConnected); | ||
} | ||
|
||
disconnect() { | ||
if(this.stompClient != null) { | ||
this.stompClient.disconnect(); | ||
} | ||
this.setConnected(false); | ||
console.log("Disconnected"); | ||
} | ||
sendMessage() { | ||
var message = document.getElementById('text').value; | ||
this.stompClient.send("/app/message", {}, message); | ||
} | ||
showMessage(message) { | ||
var response = document.getElementById('response'); | ||
var p = document.createElement('p'); | ||
p.style.wordWrap = 'break-word'; | ||
p.appendChild(document.createTextNode(message.body)); | ||
response.appendChild(p); | ||
} | ||
} | ||
|
||
setConnected(connected) { | ||
document.getElementById('connect').disabled = connected; | ||
document.getElementById('disconnect').disabled = !connected; | ||
document.getElementById('realtime').style.visibility = connected ? 'visible' : 'hidden'; | ||
document.getElementById('response').innerHTML = ''; | ||
} | ||
|
||
connect() { | ||
var socket = new SockJS('/websocket-app'); | ||
this.stompClient = Stomp.over(socket); | ||
this.stompClient.connect({}, this._onConnected); | ||
} | ||
|
||
disconnect() { | ||
if (this.stompClient != null) { | ||
this.stompClient.disconnect(); | ||
} | ||
this.setConnected(false); | ||
console.log("Disconnected"); | ||
} | ||
|
||
sendMessage() { | ||
var message = document.getElementById('text').value; | ||
this.stompClient.send("/app/message", {}, message); | ||
} | ||
|
||
showMessage(message) { | ||
var response = document.getElementById('response'); | ||
var p = document.createElement('p'); | ||
p.style.wordWrap = 'break-word'; | ||
p.appendChild(document.createTextNode(message.body)); | ||
response.appendChild(p); | ||
} | ||
|
||
} | ||
|
||
var webSocket = new WebSocketController(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
<html> | ||
<head> | ||
<title>Spring WebSocket Messaging</title> | ||
<script src="/webjars/sockjs-client/sockjs.min.js"></script> | ||
<script src="/webjars/stomp-websocket/stomp.min.js"></script> | ||
<script src="/WebSocketController.js"></script> | ||
</head> | ||
<body onload="webSocket.disconnect()"> | ||
<div> | ||
<div> | ||
<button id="connect" onclick="webSocket.connect();">Connect to Real Time Data</button> | ||
<button id="disconnect" disabled="disabled" onclick="webSocket.disconnect();"> | ||
Clear the Dashboard | ||
</button> | ||
</div> | ||
<br /> | ||
<div id="realtime"> | ||
<!--<input type="text" id="text" placeholder="Write a message..."/>--> | ||
<!--<button id="sendMessage" onclick="webSocket.sendMessage();">Send</button>--> | ||
<p id="response"></p> | ||
</div> | ||
</div> | ||
</body> | ||
<head> | ||
<title>Spring WebSocket Messaging</title> | ||
<script src="/webjars/sockjs-client/sockjs.min.js"></script> | ||
<script src="/webjars/stomp-websocket/stomp.min.js"></script> | ||
<script src="/WebSocketController.js"></script> | ||
</head> | ||
<body onload="webSocket.disconnect()"> | ||
<div> | ||
<div> | ||
<button id="connect" onclick="webSocket.connect();">Connect to Real Time Data</button> | ||
<button id="disconnect" disabled="disabled" onclick="webSocket.disconnect();"> | ||
Clear the Dashboard | ||
</button> | ||
</div> | ||
<br/> | ||
<div id="realtime"> | ||
<!--<input type="text" id="text" placeholder="Write a message..."/>--> | ||
<!--<button id="sendMessage" onclick="webSocket.sendMessage();">Send</button>--> | ||
<p id="response"></p> | ||
</div> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
version: '2' | ||
services: | ||
sonar: | ||
container_name: aiwin-rabbit | ||
image: aiwin/rabbitmq-stomp:latest | ||
ports: | ||
- 61613:61613 | ||
- 15674:15674 | ||
- 15672:15672 | ||
- 5672:5672 | ||
sonar: | ||
container_name: aiwin-rabbit | ||
image: aiwin/rabbitmq-stomp:latest | ||
ports: | ||
- 61613:61613 | ||
- 15674:15674 | ||
- 15672:15672 | ||
- 5672:5672 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters