Skip to content
This repository has been archived by the owner on Jul 3, 2021. It is now read-only.

Commit

Permalink
V4.1.1 Fixed null issues with ws by checking for null and readyState
Browse files Browse the repository at this point in the history
  • Loading branch information
thedark1337 committed Aug 12, 2015
1 parent f56d59e commit 5431ffa
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 32 deletions.
17 changes: 11 additions & 6 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -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
------
Expand Down
54 changes: 28 additions & 26 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5431ffa

Please sign in to comment.