Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <meta charset = "utf-8" />
- <title>WebSocket Test</title>
- <script language = "javascript" type = "text/javascript">
- var data = {
- UserQuestionId: 74,
- startTime: new Date().getTime() + (-1 * (new Date().getTimezoneOffset() * 60) * 1000),
- UniqueHash: '5e306bcf2c88ea00a635fbe2b41453d6'
- }
- var wsUri = "wss://stage-cad-ws.futureit.site";
- var output;
- function init() {
- output = document.getElementById("output");
- testWebSocket();
- }
- function testWebSocket() {
- websocket = new WebSocket(wsUri);
- websocket.onopen = function(evt) {
- onOpen(evt)
- };
- }
- function onOpen(evt) {
- alert("CONNECTED");
- websocket.send(JSON.stringify(data))
- websocket.onmessage = function (event) {
- console.log(event.data);
- }
- }
- window.addEventListener("load", init, false);
- function sendNoti() {
- websocket.send(JSON.stringify(data))
- }
- </script>
- <h2>WebSocket Test</h2>
- <div id = "output"></div>
- <button onclick="sendNoti()"></button>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement