diff --git a/Changelog.md b/Changelog.md index fd17697..d291126 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,13 +1,18 @@ plugAPI Changelog ================= +4.1.1 +------ +* **FIXED:** Null issue with ws (Commit [913b8d](https://github.com/plugCubed/plugAPI/cmmit/b039d5eef7ff7b8468b96e3d1da9820c32913b8d)) +* **FIXED:** A few broken links in readme (Commit [d635862](https://github.com/plugCubed/plugAPI/commit/f56d59e93ba7b1f5dd3e7ae762d42b453d635862)) + 4.1.0 ------ -* **ADDED:** Starting work on mocha test. Linting added for now. -* **CHANGED:** Linted and fixed many issues with code. -* **FIXED:** Forgot to rename function in switch case. -* **ADDED:** Default case for mutes (sets to null if time is not defined) -* **CHANGED:** JSDoc to be valid and descriptions where needed. -* **CHANGED:** Use Strict mode. +* **ADDED:** Starting work on mocha test. Linting added for now. (Commit [33375f3](https://github.com/plugCubed/plugAPI/commit/2ca5357b9c10d9251ca44022afe37a22533375f3)) +* **CHANGED:** Linted and fixed many issues with code. (Commit [33375f3](https://github.com/plugCubed/plugAPI/commit/2ca5357b9c10d9251ca44022afe37a22533375f3)) +* **FIXED:** Forgot to rename function in switch case. (Commit [33375f3](https://github.com/plugCubed/plugAPI/commit/2ca5357b9c10d9251ca44022afe37a22533375f3)) +* **ADDED:** Default case for mutes (sets to null if time is not defined) (Commit [33375f3](https://github.com/plugCubed/plugAPI/commit/2ca5357b9c10d9251ca44022afe37a22533375f3)) +* **CHANGED:** JSDoc to be valid and descriptions where needed. (Commit [33375f3](https://github.com/plugCubed/plugAPI/commit/2ca5357b9c10d9251ca44022afe37a22533375f3)) +* **CHANGED:** Use Strict mode. (Commit [33375f3](https://github.com/plugCubed/plugAPI/commit/2ca5357b9c10d9251ca44022afe37a22533375f3)) 4.0.1 ------ diff --git a/lib/client.js b/lib/client.js index dd191f4..cf999a6 100644 --- a/lib/client.js +++ b/lib/client.js @@ -346,32 +346,6 @@ var DateUtilities = { } }; -/** - * Sends serialized data to websocket - * @param {[type]} data The data to send in - * @param {[type]} [options] Optional options for ws - * @param {Function} [cb] Optional callback for ws - * @private - */ -function sendWebsocket(data, options, cb) { - data = typeof data === 'string' ? data : JSON.stringify(data); - ws.send(data, options, cb); -} - -/** - * Sends in a websocket event to plug's servers - * @param {[type]} type The Event type to send in - * @param {[type]} data The data to send in. - * @private - */ -function sendEvent(type, data) { - sendWebsocket({ - a: type, - p: data, - t: DateUtilities.getServerEpoch() - }); -} - /** * The ticker that runs through the queue and executes them when it's time * @private @@ -859,6 +833,34 @@ function connectSocket(roomSlug) { }); } +/** + * Sends serialized data to websocket + * @param {[type]} data The data to send in + * @param {[type]} [options] Optional options for ws + * @param {Function} [cb] Optional callback for ws + * @private + */ +function sendWebsocket(data, options, cb) { + data = typeof data === 'string' ? data : JSON.stringify(data); + if (ws != null && ws.readyState === WebSocket.OPEN) { + ws.send(data, options, cb); + } +} + +/** + * Sends in a websocket event to plug's servers + * @param {[type]} type The Event type to send in + * @param {[type]} data The data to send in. + * @private + */ +function sendEvent(type, data) { + sendWebsocket({ + a: type, + p: data, + t: DateUtilities.getServerEpoch() + }); +} + /** * Initialize the room with roomstate data * @param {Object} data Roomstate Data