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
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
@@ -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;
});
```
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": [
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -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
@@ -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');
@@ -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) {
1,214 changes: 886 additions & 328 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "socketcluster-client",
"description": "SocketCluster JavaScript client",
"version": "14.2.1",
"version": "14.2.2",
"homepage": "http://socketcluster.io",
"contributors": [
{
@@ -18,7 +18,7 @@
"test": "mocha --reporter spec --timeout 3000 --slow 3000"
},
"dependencies": {
"base-64": "0.1.0",
"buffer": "^5.2.1",
"clone": "2.1.1",
"component-emitter": "1.2.1",
"linked-list": "0.1.0",
255 changes: 33 additions & 222 deletions socketcluster.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions socketcluster.min.js

Large diffs are not rendered by default.