From 37ad4c0c99ef84d8ce87055b83bcb8670b82637a Mon Sep 17 00:00:00 2001 From: Charles Gould Date: Sun, 12 May 2019 23:45:51 -0400 Subject: [PATCH] Upgrade to StompJs v5 --- server/src/main/resources/static/client.js | 73 ++- server/src/main/resources/static/index.html | 5 +- .../src/main/resources/static/practice.html | 3 +- server/src/main/resources/static/practice.js | 36 +- .../src/main/resources/static/stomp-3.1.1.js | 569 ------------------ .../main/resources/static/stomp-3.1.1.min.js | 9 - 6 files changed, 66 insertions(+), 629 deletions(-) delete mode 100644 server/src/main/resources/static/stomp-3.1.1.js delete mode 100644 server/src/main/resources/static/stomp-3.1.1.min.js diff --git a/server/src/main/resources/static/client.js b/server/src/main/resources/static/client.js index 7cba2d4..e92bd51 100644 --- a/server/src/main/resources/static/client.js +++ b/server/src/main/resources/static/client.js @@ -168,16 +168,16 @@ var vm = new Vue({ return null; }, hostGame: function(e) { - client.send('/app/hostGame'); + client.publish({destination: '/app/hostGame'}) }, joinGame: function(e) { // Discard 'game-' prefix var buttonId = e.target.id; var gameId = buttonId.substr(5); - client.send('/app/joinGame', {}, gameId); + client.publish({destination: '/app/joinGame', body: gameId}) }, leaveGame: function(e) { - client.send('/app/leaveGame'); + client.publish({destination: '/app/leaveGame'}) }, removeGame: function(gameId) { var indexToRemove = null; @@ -197,7 +197,7 @@ var vm = new Vue({ } else if (e.which === KEYCODE_RETURN) { if (this.myGuess.length === 5) { - client.send("/app/guess", {}, this.myGuess); + client.publish({destination: '/app/guess', body: this.myGuess}) this.myGuess = ''; this.repaint(); } @@ -227,7 +227,7 @@ var vm = new Vue({ return; } messageInput.value = ''; - client.send('/app/chat', {}, text); + client.publish({destination: '/app/chat', body: text}) addChatMessage(this.username, text); } } @@ -279,13 +279,45 @@ function main() { webSocketProtocol = 'wss'; } - client = Stomp.client(`${webSocketProtocol}://${location.host}/stomp`); - client.heartbeat.outgoing = 25000; // send PING every 25 seconds - client.heartbeat.incoming = 0; // do NOT want PONGs from server - client.connect({}, afterConnected, function(errorMessage) { + client = new StompJs.Client({ + brokerURL: `${webSocketProtocol}://${location.host}/stomp`, + connectHeaders: {}, + //reconnectDelay: 5000, // TODO: implement reconnect functionality + reconnectDelay: 0, // Disable automatic reconnects + heartbeatIncoming: 25000, // send PING every 25 seconds + heartbeatOutgoing: 25000, // receive PONG every 25 seconds + //debug: function (str) { console.log(str); } // Print debug logs + }); + + client.onConnect = function(frame) { + afterConnected(frame); + } + + // Will be invoked in case of error encountered at broker. + // Bad login/passcode typically will cause an error. + // Complaint brokers will set `message` header with a brief message. Body may contain details. + // Compliant brokers will terminate the connection after any error. + client.onStompError = function(frame) { + console.log('Broker reported error: ' + frame.headers['message']); + console.log('Additional details: ' + frame.body); + var errorMessage = frame.headers['message']; addChatAnnouncement(errorMessage); addChatAnnouncement('Please reload the page!'); - }); + } + + client.onWebSocketClose = function(wsCloseEvent) { + console.log('WebSocket close event: ' + JSON.stringify(wsCloseEvent)); + addChatAnnouncement('WebSocket closed!'); + addChatAnnouncement('Please reload the page!'); + } + + client.onWebSocketError = function(wsErrorEvent) { + console.log('WebSocket error event: ' + JSON.stringify(wsErrorEvent)); + addChatAnnouncement('WebSocket error!'); + addChatAnnouncement('Please reload the page!'); + } + + client.activate(); var usernameInput = document.getElementById('nicknameInput'); @@ -318,7 +350,7 @@ function main() { usernameSubscription = client.subscribe(usernameTopic, usernameHandler); client.subscribe('/topic/userJoined', onUserJoined); } - client.send('/app/setUsername', {}, usernameValue); + client.publish({destination: '/app/setUsername', body: usernameValue}) } }); usernameInput.addEventListener('keyup', function(e) { @@ -414,15 +446,6 @@ function isCharacterUppercase(charCode) { return charCode >= 65 && charCode <= 90; } -function isValidResult(result) { - for (var i = 0; i < 5; i++) { - if (result[i] !== 0 && result[i] !== 1 && result[i] !== 2) { - return false; - } - } - return true; -} - function onChat(message) { var chatMessage = JSON.parse(message.body); var messageSender = chatMessage.username; @@ -432,7 +455,7 @@ function onChat(message) { } else if (messageSender === vm.username) { // Ignore messages sent by yourself } else { - console.log('Message from ' + messageSender + ": " + messageBody); + console.log('Message from ' + messageSender + ': ' + messageBody); addChatMessage(messageSender, messageBody); } } @@ -524,30 +547,28 @@ function onOpponentJoined(message) { } function onOpponentReport(message) { + console.log('Opponent report: ' + message.body); var report = JSON.parse(message.body); if (report.correct === true) { var guess = report.guess; var firstLetter = report.firstLetter; - console.log('Opponent guessed correctly! ' + guess); vm.opponentScore = vm.opponentScore + 100; vm.lastWord = guess; vm.reset(firstLetter, false); vm.repaint(); } else { var result = report.result; - console.log('Opponent result: ' + result); vm.opponentResults.push(result); vm.repaint(); } } function onPlayerReport(message) { + console.log('My report: ' + message.body); var report = JSON.parse(message.body); - console.log('My report: ' + report); if (report.correct === true) { var guess = report.guess; var firstLetter = report.firstLetter; - console.log('I guessed correctly!'); vm.myScore = vm.myScore + 100; vm.lastWord = guess; vm.reset(firstLetter, false); @@ -555,8 +576,6 @@ function onPlayerReport(message) { } else { var guess = report.guess; var result = report.result; - console.log('My result: ' + result); - // TODO: use isValidResult function if (result[0] === 9) { vm.myGuesses.push('-----'); } else { diff --git a/server/src/main/resources/static/index.html b/server/src/main/resources/static/index.html index 7c59814..79a9c41 100644 --- a/server/src/main/resources/static/index.html +++ b/server/src/main/resources/static/index.html @@ -5,7 +5,8 @@ Lingo - + +
@@ -64,8 +65,6 @@
- - diff --git a/server/src/main/resources/static/practice.html b/server/src/main/resources/static/practice.html index eaf5dba..6a1c83d 100644 --- a/server/src/main/resources/static/practice.html +++ b/server/src/main/resources/static/practice.html @@ -11,8 +11,7 @@ - - + diff --git a/server/src/main/resources/static/practice.js b/server/src/main/resources/static/practice.js index f97d6de..6b313d0 100644 --- a/server/src/main/resources/static/practice.js +++ b/server/src/main/resources/static/practice.js @@ -37,14 +37,24 @@ function start() { webSocketProtocol = 'wss'; } - client = Stomp.client(`${webSocketProtocol}://${location.host}/stomp`); + client = new StompJs.Client({ + brokerURL: `${webSocketProtocol}://${location.host}/stomp`, + connectHeaders: {}, + //reconnectDelay: 5000, // TODO: implement reconnect functionality + reconnectDelay: 0, // Disable automatic reconnects + heartbeatIncoming: 25000, // send PING every 25 seconds + heartbeatOutgoing: 25000, // receive PONG every 25 seconds + //debug: function (str) { console.log(str); } // Print debug logs + }); - client.connect({}, function(frame) { + client.onConnect = function(frame) { subscribeToPracticeGame(); subscribeToPracticeReports(); subscribeToPracticeWordSkipped(); - client.send('/app/practiceGame'); - }); + client.publish({destination: '/app/practiceGame'}); + } + + client.activate(); } // special keys @@ -59,7 +69,7 @@ function addKeydownListener() { // return else if (e.which === 13) { if (myGuess.length === 5) { - client.send("/app/practiceGuess", {}, myGuess); + client.publish({destination: '/app/practiceGuess', body: myGuess}); myGuess = ''; repaint(); } @@ -87,7 +97,7 @@ function addKeypressListener() { // skip button function addSkipButtonListener() { document.getElementById('skipButton').addEventListener('click', function(e) { - client.send("/app/practiceSkip"); + client.publish({destination: '/app/practiceSkip'}); }); } @@ -205,15 +215,6 @@ function isCharacterUppercase(charCode) { return charCode >= 65 && charCode <= 90; } -function isValidResult(result) { - for (var i = 0; i < 5; i++) { - if (result[i] !== 0 && result[i] !== 1 && result[i] !== 2) { - return false; - } - } - return true; -} - function repaint() { // clear the canvas ctx.clearRect(0, 0, canvas.width, canvas.height); @@ -247,12 +248,11 @@ function subscribeToPracticeGame() { function subscribeToPracticeReports() { client.subscribe('/user/topic/practiceReports', function(message) { + console.log('My report: ' + message.body); var report = JSON.parse(message.body); - console.log('My report: ' + report); if (report.correct === true) { var guess = report.guess; var firstLetter = report.firstLetter; - console.log('I guessed correctly!'); myScore = myScore + 100; lastWord = guess; reset(firstLetter, false); @@ -260,8 +260,6 @@ function subscribeToPracticeReports() { } else { var guess = report.guess; var result = report.result; - console.log('My result: ' + result); - // TODO: use isValidResult function if (result[0] === 9) { myGuesses.push('-----'); } else { diff --git a/server/src/main/resources/static/stomp-3.1.1.js b/server/src/main/resources/static/stomp-3.1.1.js deleted file mode 100644 index 484879d..0000000 --- a/server/src/main/resources/static/stomp-3.1.1.js +++ /dev/null @@ -1,569 +0,0 @@ -// Generated by CoffeeScript 1.12.6 - -/* - Stomp Over WebSocket http://www.jmesnil.net/stomp-websocket/doc/ | Apache License V2.0 - - Copyright (C) 2010-2013 [Jeff Mesnil](http://jmesnil.net/) - Copyright (C) 2012 [FuseSource, Inc.](http://fusesource.com) - Copyright (C) 2017 [Deepak Kumar](https://www.kreatio.com) - */ - -(function() { - var Byte, Client, Frame, Stomp, - hasProp = {}.hasOwnProperty, - slice = [].slice; - - Byte = { - LF: '\x0A', - NULL: '\x00' - }; - - Frame = (function() { - var unmarshallSingle; - - function Frame(command1, headers1, body1) { - this.command = command1; - this.headers = headers1 != null ? headers1 : {}; - this.body = body1 != null ? body1 : ''; - } - - Frame.prototype.toString = function() { - var lines, name, ref, skipContentLength, value; - lines = [this.command]; - skipContentLength = (this.headers['content-length'] === false) ? true : false; - if (skipContentLength) { - delete this.headers['content-length']; - } - ref = this.headers; - for (name in ref) { - if (!hasProp.call(ref, name)) continue; - value = ref[name]; - lines.push(name + ":" + value); - } - if (this.body && !skipContentLength) { - lines.push("content-length:" + (Frame.sizeOfUTF8(this.body))); - } - lines.push(Byte.LF + this.body); - return lines.join(Byte.LF); - }; - - Frame.sizeOfUTF8 = function(s) { - if (s) { - return encodeURI(s).match(/%..|./g).length; - } else { - return 0; - } - }; - - unmarshallSingle = function(data) { - var body, chr, command, divider, headerLines, headers, i, idx, j, k, len, len1, line, ref, ref1, ref2, start, trim; - divider = data.search(RegExp("" + Byte.LF + Byte.LF)); - headerLines = data.substring(0, divider).split(Byte.LF); - command = headerLines.shift(); - headers = {}; - trim = function(str) { - return str.replace(/^\s+|\s+$/g, ''); - }; - ref = headerLines.reverse(); - for (j = 0, len1 = ref.length; j < len1; j++) { - line = ref[j]; - idx = line.indexOf(':'); - headers[trim(line.substring(0, idx))] = trim(line.substring(idx + 1)); - } - body = ''; - start = divider + 2; - if (headers['content-length']) { - len = parseInt(headers['content-length']); - body = ('' + data).substring(start, start + len); - } else { - chr = null; - for (i = k = ref1 = start, ref2 = data.length; ref1 <= ref2 ? k < ref2 : k > ref2; i = ref1 <= ref2 ? ++k : --k) { - chr = data.charAt(i); - if (chr === Byte.NULL) { - break; - } - body += chr; - } - } - return new Frame(command, headers, body); - }; - - Frame.unmarshall = function(datas) { - var frame, frames, last_frame, r; - frames = datas.split(RegExp("" + Byte.NULL + Byte.LF + "*")); - r = { - frames: [], - partial: '' - }; - r.frames = (function() { - var j, len1, ref, results; - ref = frames.slice(0, -1); - results = []; - for (j = 0, len1 = ref.length; j < len1; j++) { - frame = ref[j]; - results.push(unmarshallSingle(frame)); - } - return results; - })(); - last_frame = frames.slice(-1)[0]; - if (last_frame === Byte.LF || (last_frame.search(RegExp("" + Byte.NULL + Byte.LF + "*$"))) !== -1) { - r.frames.push(unmarshallSingle(last_frame)); - } else { - r.partial = last_frame; - } - return r; - }; - - Frame.marshall = function(command, headers, body) { - var frame; - frame = new Frame(command, headers, body); - return frame.toString() + Byte.NULL; - }; - - return Frame; - - })(); - - Client = (function() { - var now; - - function Client(ws_fn) { - this.ws_fn = function() { - var ws; - ws = ws_fn(); - ws.binaryType = "arraybuffer"; - return ws; - }; - this.reconnect_delay = 0; - this.counter = 0; - this.connected = false; - this.heartbeat = { - outgoing: 10000, - incoming: 10000 - }; - this.maxWebSocketFrameSize = 16 * 1024; - this.subscriptions = {}; - this.partialData = ''; - } - - Client.prototype.debug = function(message) { - var ref; - return typeof window !== "undefined" && window !== null ? (ref = window.console) != null ? ref.log(message) : void 0 : void 0; - }; - - now = function() { - if (Date.now) { - return Date.now(); - } else { - return new Date().valueOf; - } - }; - - Client.prototype._transmit = function(command, headers, body) { - var out; - out = Frame.marshall(command, headers, body); - if (typeof this.debug === "function") { - this.debug(">>> " + out); - } - while (true) { - if (out.length > this.maxWebSocketFrameSize) { - this.ws.send(out.substring(0, this.maxWebSocketFrameSize)); - out = out.substring(this.maxWebSocketFrameSize); - if (typeof this.debug === "function") { - this.debug("remaining = " + out.length); - } - } else { - return this.ws.send(out); - } - } - }; - - Client.prototype._setupHeartbeat = function(headers) { - var ref, ref1, serverIncoming, serverOutgoing, ttl, v; - if ((ref = headers.version) !== Stomp.VERSIONS.V1_1 && ref !== Stomp.VERSIONS.V1_2) { - return; - } - ref1 = (function() { - var j, len1, ref1, results; - ref1 = headers['heart-beat'].split(","); - results = []; - for (j = 0, len1 = ref1.length; j < len1; j++) { - v = ref1[j]; - results.push(parseInt(v)); - } - return results; - })(), serverOutgoing = ref1[0], serverIncoming = ref1[1]; - if (!(this.heartbeat.outgoing === 0 || serverIncoming === 0)) { - ttl = Math.max(this.heartbeat.outgoing, serverIncoming); - if (typeof this.debug === "function") { - this.debug("send PING every " + ttl + "ms"); - } - this.pinger = Stomp.setInterval(ttl, (function(_this) { - return function() { - _this.ws.send(Byte.LF); - return typeof _this.debug === "function" ? _this.debug(">>> PING") : void 0; - }; - })(this)); - } - if (!(this.heartbeat.incoming === 0 || serverOutgoing === 0)) { - ttl = Math.max(this.heartbeat.incoming, serverOutgoing); - if (typeof this.debug === "function") { - this.debug("check PONG every " + ttl + "ms"); - } - return this.ponger = Stomp.setInterval(ttl, (function(_this) { - return function() { - var delta; - delta = now() - _this.serverActivity; - if (delta > ttl * 2) { - if (typeof _this.debug === "function") { - _this.debug("did not receive server activity for the last " + delta + "ms"); - } - return _this.ws.close(); - } - }; - })(this)); - } - }; - - Client.prototype._parseConnect = function() { - var args, connectCallback, errorCallback, headers; - args = 1 <= arguments.length ? slice.call(arguments, 0) : []; - headers = {}; - switch (args.length) { - case 2: - headers = args[0], connectCallback = args[1]; - break; - case 3: - if (args[1] instanceof Function) { - headers = args[0], connectCallback = args[1], errorCallback = args[2]; - } else { - headers.login = args[0], headers.passcode = args[1], connectCallback = args[2]; - } - break; - case 4: - headers.login = args[0], headers.passcode = args[1], connectCallback = args[2], errorCallback = args[3]; - break; - default: - headers.login = args[0], headers.passcode = args[1], connectCallback = args[2], errorCallback = args[3], headers.host = args[4]; - } - return [headers, connectCallback, errorCallback]; - }; - - Client.prototype.connect = function() { - var args, out; - args = 1 <= arguments.length ? slice.call(arguments, 0) : []; - out = this._parseConnect.apply(this, args); - this.headers = out[0], this.connectCallback = out[1], this.errorCallback = out[2]; - return this._connect(); - }; - - Client.prototype._connect = function() { - var errorCallback, headers; - headers = this.headers; - errorCallback = this.errorCallback; - if (typeof this.debug === "function") { - this.debug("Opening Web Socket..."); - } - this.ws = this.ws_fn(); - this.ws.onmessage = (function(_this) { - return function(evt) { - var arr, c, client, data, frame, j, len1, messageID, onreceive, ref, results, subscription, unmarshalledData; - data = typeof ArrayBuffer !== 'undefined' && evt.data instanceof ArrayBuffer ? (arr = new Uint8Array(evt.data), typeof _this.debug === "function" ? _this.debug("--- got data length: " + arr.length) : void 0, ((function() { - var j, len1, results; - results = []; - for (j = 0, len1 = arr.length; j < len1; j++) { - c = arr[j]; - results.push(String.fromCharCode(c)); - } - return results; - })()).join('')) : evt.data; - _this.serverActivity = now(); - if (data === Byte.LF) { - if (typeof _this.debug === "function") { - _this.debug("<<< PONG"); - } - return; - } - if (typeof _this.debug === "function") { - _this.debug("<<< " + data); - } - unmarshalledData = Frame.unmarshall(_this.partialData + data); - _this.partialData = unmarshalledData.partial; - ref = unmarshalledData.frames; - results = []; - for (j = 0, len1 = ref.length; j < len1; j++) { - frame = ref[j]; - switch (frame.command) { - case "CONNECTED": - if (typeof _this.debug === "function") { - _this.debug("connected to server " + frame.headers.server); - } - _this.connected = true; - _this.version = frame.headers.version; - _this._setupHeartbeat(frame.headers); - results.push(typeof _this.connectCallback === "function" ? _this.connectCallback(frame) : void 0); - break; - case "MESSAGE": - subscription = frame.headers.subscription; - onreceive = _this.subscriptions[subscription] || _this.onreceive; - if (onreceive) { - client = _this; - if (_this.version === Stomp.VERSIONS.V1_2) { - messageID = frame.headers["ack"]; - } else { - messageID = frame.headers["message-id"]; - } - frame.ack = function(headers) { - if (headers == null) { - headers = {}; - } - return client.ack(messageID, subscription, headers); - }; - frame.nack = function(headers) { - if (headers == null) { - headers = {}; - } - return client.nack(messageID, subscription, headers); - }; - results.push(onreceive(frame)); - } else { - results.push(typeof _this.debug === "function" ? _this.debug("Unhandled received MESSAGE: " + frame) : void 0); - } - break; - case "RECEIPT": - if (frame.headers["receipt-id"] === _this.closeReceipt) { - _this.ws.onclose = null; - _this.ws.close(); - results.push(_this._cleanUp()); - } else { - results.push(typeof _this.onreceipt === "function" ? _this.onreceipt(frame) : void 0); - } - break; - case "ERROR": - results.push(typeof errorCallback === "function" ? errorCallback(frame) : void 0); - break; - default: - results.push(typeof _this.debug === "function" ? _this.debug("Unhandled frame: " + frame) : void 0); - } - } - return results; - }; - })(this); - this.ws.onclose = (function(_this) { - return function() { - var msg; - msg = "Whoops! Lost connection to " + _this.ws.url; - if (typeof _this.debug === "function") { - _this.debug(msg); - } - _this._cleanUp(); - if (typeof errorCallback === "function") { - errorCallback(msg); - } - return _this._schedule_reconnect(); - }; - })(this); - return this.ws.onopen = (function(_this) { - return function() { - if (typeof _this.debug === "function") { - _this.debug('Web Socket Opened...'); - } - headers["accept-version"] = Stomp.VERSIONS.supportedVersions(); - headers["heart-beat"] = [_this.heartbeat.outgoing, _this.heartbeat.incoming].join(','); - return _this._transmit("CONNECT", headers); - }; - })(this); - }; - - Client.prototype._schedule_reconnect = function() { - if (this.reconnect_delay > 0) { - this.debug("STOMP: scheduling reconnection in " + this.reconnect_delay + "ms"); - return setTimeout((function(_this) { - return function() { - if (_this.connected) { - return typeof _this.debug === "function" ? _this.debug('STOMP: already connected') : void 0; - } else { - if (typeof _this.debug === "function") { - _this.debug('STOMP: attempting to reconnect'); - } - return _this._connect(); - } - }; - })(this), this.reconnect_delay); - } - }; - - Client.prototype.disconnect = function(disconnectCallback, headers) { - if (headers == null) { - headers = {}; - } - if (!headers.receipt) { - headers.receipt = "close-" + this.counter++; - } - this.closeReceipt = headers.receipt; - this._transmit("DISCONNECT", headers); - return typeof disconnectCallback === "function" ? disconnectCallback() : void 0; - }; - - Client.prototype._cleanUp = function() { - this.connected = false; - this.subscriptions = {}; - this.partial = ''; - if (this.pinger) { - Stomp.clearInterval(this.pinger); - } - if (this.ponger) { - return Stomp.clearInterval(this.ponger); - } - }; - - Client.prototype.send = function(destination, headers, body) { - if (headers == null) { - headers = {}; - } - if (body == null) { - body = ''; - } - headers.destination = destination; - return this._transmit("SEND", headers, body); - }; - - Client.prototype.subscribe = function(destination, callback, headers) { - var client; - if (headers == null) { - headers = {}; - } - if (!headers.id) { - headers.id = "sub-" + this.counter++; - } - headers.destination = destination; - this.subscriptions[headers.id] = callback; - this._transmit("SUBSCRIBE", headers); - client = this; - return { - id: headers.id, - unsubscribe: function(hdrs) { - return client.unsubscribe(headers.id, hdrs); - } - }; - }; - - Client.prototype.unsubscribe = function(id, headers) { - if (headers == null) { - headers = {}; - } - delete this.subscriptions[id]; - headers.id = id; - return this._transmit("UNSUBSCRIBE", headers); - }; - - Client.prototype.begin = function(transaction_id) { - var client, txid; - txid = transaction_id || "tx-" + this.counter++; - this._transmit("BEGIN", { - transaction: txid - }); - client = this; - return { - id: txid, - commit: function() { - return client.commit(txid); - }, - abort: function() { - return client.abort(txid); - } - }; - }; - - Client.prototype.commit = function(transaction_id) { - return this._transmit("COMMIT", { - transaction: transaction_id - }); - }; - - Client.prototype.abort = function(transaction_id) { - return this._transmit("ABORT", { - transaction: transaction_id - }); - }; - - Client.prototype.ack = function(messageID, subscription, headers) { - if (headers == null) { - headers = {}; - } - if (this.version === Stomp.VERSIONS.V1_2) { - headers["id"] = messageID; - } else { - headers["message-id"] = messageID; - } - headers.subscription = subscription; - return this._transmit("ACK", headers); - }; - - Client.prototype.nack = function(messageID, subscription, headers) { - if (headers == null) { - headers = {}; - } - if (this.version === Stomp.VERSIONS.V1_2) { - headers["id"] = messageID; - } else { - headers["message-id"] = messageID; - } - headers.subscription = subscription; - return this._transmit("NACK", headers); - }; - - return Client; - - })(); - - Stomp = { - VERSIONS: { - V1_0: '1.0', - V1_1: '1.1', - V1_2: '1.2', - supportedVersions: function() { - return '1.2,1.1,1.0'; - } - }, - client: function(url, protocols) { - var ws_fn; - if (protocols == null) { - protocols = ['v10.stomp', 'v11.stomp', 'v12.stomp']; - } - ws_fn = function() { - var klass; - klass = Stomp.WebSocketClass || WebSocket; - return new klass(url, protocols); - }; - return new Client(ws_fn); - }, - over: function(ws) { - var ws_fn; - ws_fn = typeof ws === "function" ? ws : function() { - return ws; - }; - return new Client(ws_fn); - }, - Frame: Frame - }; - - Stomp.setInterval = function(interval, f) { - return setInterval(f, interval); - }; - - Stomp.clearInterval = function(id) { - return clearInterval(id); - }; - - if (typeof exports !== "undefined" && exports !== null) { - exports.Stomp = Stomp; - } - - if (typeof window !== "undefined" && window !== null) { - window.Stomp = Stomp; - } else if (!exports) { - self.Stomp = Stomp; - } - -}).call(this); diff --git a/server/src/main/resources/static/stomp-3.1.1.min.js b/server/src/main/resources/static/stomp-3.1.1.min.js deleted file mode 100644 index 63e6329..0000000 --- a/server/src/main/resources/static/stomp-3.1.1.min.js +++ /dev/null @@ -1,9 +0,0 @@ -// Generated by CoffeeScript 1.12.6 -/* - Stomp Over WebSocket http://www.jmesnil.net/stomp-websocket/doc/ | Apache License V2.0 - - Copyright (C) 2010-2013 [Jeff Mesnil](http://jmesnil.net/) - Copyright (C) 2012 [FuseSource, Inc.](http://fusesource.com) - Copyright (C) 2017 [Deepak Kumar](https://www.kreatio.com) - */ -(function(){var t,e,n,i,r={}.hasOwnProperty,o=[].slice;t={LF:"\n",NULL:"\0"};n=function(){var e;function n(t,e,n){this.command=t;this.headers=e!=null?e:{};this.body=n!=null?n:""}n.prototype.toString=function(){var e,i,o,s,u;e=[this.command];s=this.headers["content-length"]===false?true:false;if(s){delete this.headers["content-length"]}o=this.headers;for(i in o){if(!r.call(o,i))continue;u=o[i];e.push(i+":"+u)}if(this.body&&!s){e.push("content-length:"+n.sizeOfUTF8(this.body))}e.push(t.LF+this.body);return e.join(t.LF)};n.sizeOfUTF8=function(t){if(t){return encodeURI(t).match(/%..|./g).length}else{return 0}};e=function(e){var i,r,o,s,u,c,a,f,h,l,p,d,b,g,v,y,m,S;s=e.search(RegExp(""+t.LF+t.LF));u=e.substring(0,s).split(t.LF);o=u.shift();c={};S=function(t){return t.replace(/^\s+|\s+$/g,"")};g=u.reverse();for(h=0,d=g.length;hy;a=v<=y?++l:--l){r=e.charAt(a);if(r===t.NULL){break}i+=r}}return new n(o,c,i)};n.unmarshall=function(n){var i,r,o,s;r=n.split(RegExp(""+t.NULL+t.LF+"*"));s={frames:[],partial:""};s.frames=function(){var t,n,o,s;o=r.slice(0,-1);s=[];for(t=0,n=o.length;t>> "+r)}while(true){if(r.length>this.maxWebSocketFrameSize){this.ws.send(r.substring(0,this.maxWebSocketFrameSize));r=r.substring(this.maxWebSocketFrameSize);if(typeof this.debug==="function"){this.debug("remaining = "+r.length)}}else{return this.ws.send(r)}}};r.prototype._setupHeartbeat=function(n){var r,o,s,u,c,a;if((r=n.version)!==i.VERSIONS.V1_1&&r!==i.VERSIONS.V1_2){return}o=function(){var t,e,i,r;i=n["heart-beat"].split(",");r=[];for(t=0,e=i.length;t>> PING"):void 0}}(this))}if(!(this.heartbeat.incoming===0||u===0)){c=Math.max(this.heartbeat.incoming,u);if(typeof this.debug==="function"){this.debug("check PONG every "+c+"ms")}return this.ponger=i.setInterval(c,function(t){return function(){var n;n=e()-t.serverActivity;if(n>c*2){if(typeof t.debug==="function"){t.debug("did not receive server activity for the last "+n+"ms")}return t.ws.close()}}}(this))}};r.prototype._parseConnect=function(){var t,e,n,i;t=1<=arguments.length?o.call(arguments,0):[];i={};switch(t.length){case 2:i=t[0],e=t[1];break;case 3:if(t[1]instanceof Function){i=t[0],e=t[1],n=t[2]}else{i.login=t[0],i.passcode=t[1],e=t[2]}break;case 4:i.login=t[0],i.passcode=t[1],e=t[2],n=t[3];break;default:i.login=t[0],i.passcode=t[1],e=t[2],n=t[3],i.host=t[4]}return[i,e,n]};r.prototype.connect=function(){var t,e;t=1<=arguments.length?o.call(arguments,0):[];e=this._parseConnect.apply(this,t);this.headers=e[0],this.connectCallback=e[1],this.errorCallback=e[2];return this._connect()};r.prototype._connect=function(){var r,o;o=this.headers;r=this.errorCallback;if(typeof this.debug==="function"){this.debug("Opening Web Socket...")}this.ws=this.ws_fn();this.ws.onmessage=function(o){return function(s){var u,c,a,f,h,l,p,d,b,g,v,y,m;f=typeof ArrayBuffer!=="undefined"&&s.data instanceof ArrayBuffer?(u=new Uint8Array(s.data),typeof o.debug==="function"?o.debug("--- got data length: "+u.length):void 0,function(){var t,e,n;n=[];for(t=0,e=u.length;t0){this.debug("STOMP: scheduling reconnection in "+this.reconnect_delay+"ms");return setTimeout(function(t){return function(){if(t.connected){return typeof t.debug==="function"?t.debug("STOMP: already connected"):void 0}else{if(typeof t.debug==="function"){t.debug("STOMP: attempting to reconnect")}return t._connect()}}}(this),this.reconnect_delay)}};r.prototype.disconnect=function(t,e){if(e==null){e={}}if(!e.receipt){e.receipt="close-"+this.counter++}this.closeReceipt=e.receipt;this._transmit("DISCONNECT",e);return typeof t==="function"?t():void 0};r.prototype._cleanUp=function(){this.connected=false;this.subscriptions={};this.partial="";if(this.pinger){i.clearInterval(this.pinger)}if(this.ponger){return i.clearInterval(this.ponger)}};r.prototype.send=function(t,e,n){if(e==null){e={}}if(n==null){n=""}e.destination=t;return this._transmit("SEND",e,n)};r.prototype.subscribe=function(t,e,n){var i;if(n==null){n={}}if(!n.id){n.id="sub-"+this.counter++}n.destination=t;this.subscriptions[n.id]=e;this._transmit("SUBSCRIBE",n);i=this;return{id:n.id,unsubscribe:function(t){return i.unsubscribe(n.id,t)}}};r.prototype.unsubscribe=function(t,e){if(e==null){e={}}delete this.subscriptions[t];e.id=t;return this._transmit("UNSUBSCRIBE",e)};r.prototype.begin=function(t){var e,n;n=t||"tx-"+this.counter++;this._transmit("BEGIN",{transaction:n});e=this;return{id:n,commit:function(){return e.commit(n)},abort:function(){return e.abort(n)}}};r.prototype.commit=function(t){return this._transmit("COMMIT",{transaction:t})};r.prototype.abort=function(t){return this._transmit("ABORT",{transaction:t})};r.prototype.ack=function(t,e,n){if(n==null){n={}}if(this.version===i.VERSIONS.V1_2){n["id"]=t}else{n["message-id"]=t}n.subscription=e;return this._transmit("ACK",n)};r.prototype.nack=function(t,e,n){if(n==null){n={}}if(this.version===i.VERSIONS.V1_2){n["id"]=t}else{n["message-id"]=t}n.subscription=e;return this._transmit("NACK",n)};return r}();i={VERSIONS:{V1_0:"1.0",V1_1:"1.1",V1_2:"1.2",supportedVersions:function(){return"1.2,1.1,1.0"}},client:function(t,n){var r;if(n==null){n=["v10.stomp","v11.stomp","v12.stomp"]}r=function(){var e;e=i.WebSocketClass||WebSocket;return new e(t,n)};return new e(r)},over:function(t){var n;n=typeof t==="function"?t:function(){return t};return new e(n)},Frame:n};i.setInterval=function(t,e){return setInterval(e,t)};i.clearInterval=function(t){return clearInterval(t)};if(typeof exports!=="undefined"&&exports!==null){exports.Stomp=i}if(typeof window!=="undefined"&&window!==null){window.Stomp=i}else if(!exports){self.Stomp=i}}).call(this);