Skip to content

fix example not compatible with server skeleton #126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ socket.on('connect', function () {
console.log('CONNECTED');
});

// Listen to an event called 'rand' from the server
socket.on('rand', function (num) {
console.log('RANDOM: ' + num);
// Listen to an event called 'random' from the server
socket.on('random', function (data) {
console.log('RANDOM: ' + data.number);
var curHTML = document.body.innerHTML;
curHTML += 'RANDOM: ' + num + '<br />';
curHTML += 'RANDOM: ' + data.number + '<br />';
document.body.innerHTML = curHTML;
});
```
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "socketcluster-client",
"main": "socketcluster.js",
"version": "14.2.1",
"version": "14.2.2",
"homepage": "https://github.com/SocketCluster/socketcluster-client",
"description": "SocketCluster JavaScript client",
"authors": [
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ module.exports.destroy = function (socket) {

module.exports.clients = factory.clients;

module.exports.version = '14.2.1';
module.exports.version = '14.2.2';
28 changes: 3 additions & 25 deletions lib/scclientsocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var formatter = require('sc-formatter');
var SCTransport = require('./sctransport').SCTransport;
var querystring = require('querystring');
var LinkedList = require('linked-list');
var base64 = require('base-64');
var Buffer = require('buffer/').Buffer;
var clone = require('clone');

var scErrors = require('sc-errors');
Expand Down Expand Up @@ -380,33 +380,11 @@ SCClientSocket.prototype._changeToAuthenticatedState = function (signedAuthToken
};

SCClientSocket.prototype.decodeBase64 = function (encodedString) {
var decodedString;
if (typeof Buffer === 'undefined') {
if (global.atob) {
decodedString = global.atob(encodedString);
} else {
decodedString = base64.decode(encodedString);
}
} else {
var buffer = Buffer.from(encodedString, 'base64');
decodedString = buffer.toString('utf8');
}
return decodedString;
return Buffer.from(encodedString, 'base64').toString('utf8');
};

SCClientSocket.prototype.encodeBase64 = function (decodedString) {
var encodedString;
if (typeof Buffer === 'undefined') {
if (global.btoa) {
encodedString = global.btoa(decodedString);
} else {
encodedString = base64.encode(decodedString);
}
} else {
var buffer = Buffer.from(decodedString, 'utf8');
encodedString = buffer.toString('base64');
}
return encodedString;
return Buffer.from(decodedString, 'utf8').toString('base64');
};

SCClientSocket.prototype._extractAuthTokenData = function (signedAuthToken) {
Expand Down
Loading