Skip to content

Commit

Permalink
v15.0.0 - Rename asyngular to socketcluster
Browse files Browse the repository at this point in the history
  • Loading branch information
jondubois committed Jan 20, 2020
1 parent cff096d commit 4830adc
Show file tree
Hide file tree
Showing 11 changed files with 135 additions and 118 deletions.
40 changes: 20 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
Asyngular JavaScript client
SocketCluster JavaScript client
======

Client module for Asyngular.
Client module for SocketCluster.

## Setting up

You will need to install both ```asyngular-client``` and ```asyngular-server``` (https://github.com/SocketCluster/asyngular-server).
You will need to install both ```socketcluster-client``` and ```socketcluster-server``` (https://github.com/SocketCluster/socketcluster-server).

To install this module:
```bash
npm install asyngular-client
npm install socketcluster-client
```

## How to use

The asyngular-client script is called `asyngular-client.js` (located in the main asyngular-client directory).
The socketcluster-client script is called `socketcluster-client.js` (located in the main socketcluster-client directory).
Embed it in your HTML page like this:
```html
<script type="text/javascript" src="/asyngular-client.js"></script>
<script type="text/javascript" src="/socketcluster-client.js"></script>
```
\* Note that the src attribute may be different depending on how you setup your HTTP server.

Once you have embedded the client `asyngular-client.js` into your page, you will gain access to a global `asyngularClient` object.
Once you have embedded the client `socketcluster-client.js` into your page, you will gain access to a global `socketClusterClient` object.
You may also use CommonJS `require` or ES6 module imports.

### Connect to a server

```js
let socket = asyngularClient.create({
let socket = socketClusterClient.create({
hostname: 'localhost',
port: 8000
});
Expand Down Expand Up @@ -138,19 +138,19 @@ let options = {
rejectUnauthorized: false // Only necessary during debug if using a self-signed certificate
};
// Initiate the connection to the server
let socket = asyngularClient.create(options);
let socket = socketClusterClient.create(options);
```

For more detailed examples of how to use Asyngular, see `test/integration.js`.
Also, see tests from the `asyngular-server` module.
For more detailed examples of how to use SocketCluster, see `test/integration.js`.
Also, see tests from the `socketcluster-server` module.

### Connect Options

See all available options: https://asyngular.io/docs/api-asyngular-client/
See all available options: https://socketcluster.io/

```js
let options = {
path: '/asyngular/',
path: '/socketcluster/',
port: 8000,
hostname: '127.0.0.1',
autoConnect: true,
Expand All @@ -177,8 +177,8 @@ let options = {

## Running the tests

- Clone this repo: `git clone [email protected]:SocketCluster/asyngular-client.git`
- Navigate to project directory: `cd asyngular-client`
- Clone this repo: `git clone [email protected]:SocketCluster/socketcluster-client.git`
- Navigate to project directory: `cd socketcluster-client`
- Install all dependencies: `npm install`
- Run the tests: `npm test`

Expand All @@ -187,7 +187,7 @@ let options = {
For compatibility with an existing SocketCluster server, set the `protocolVersion` to `1` and make sure that the `path` matches your old server path:

```js
let socket = asyngularClient.create({
let socket = socketClusterClient.create({
protocolVersion: 1,
path: '/socketcluster/'
});
Expand All @@ -198,7 +198,7 @@ let socket = asyngularClient.create({
### Install all dependencies

```bash
cd asyngular-client
cd socketcluster-client

npm install -g gulp gulp-cli browserify uglify-es

Expand All @@ -207,21 +207,21 @@ npm install

### Building

To build the Asyngular client:
To build the SocketCluster client:

```bash
npm run build
```

## Change log

See the 'releases' section for changes: https://github.com/SocketCluster/asyngular-client/releases
See the 'releases' section for changes: https://github.com/SocketCluster/socketcluster-client/releases

## License

(The MIT License)

Copyright (c) 2013-2019 Asyngular.io
Copyright (c) 2013-2019 SocketCluster.io

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
4 changes: 0 additions & 4 deletions asyngular-client.min.js

This file was deleted.

2 changes: 1 addition & 1 deletion browserify-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

SDK_VERSION=$(cat package.json | sed -n -e '/version/ s/.*: *"\([^"]*\).*/\1/p')
echo "Building JavaScript SDK v$SDK_VERSION...\n"
browserify -s asyngular index.js > asyngular-client.js && uglifyjs asyngular-client.js -o asyngular-client.min.js
browserify -s socketcluster index.js > socketcluster-client.js && uglifyjs socketcluster-client.js -o socketcluster-client.min.js
2 changes: 1 addition & 1 deletion gulp-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
SDK_VERSION=$(cat package.json | sed -n -e '/version/ s/.*: *"\([^"]*\).*/\1/p')
echo "Building JavaScript SDK v$SDK_VERSION...\n"
echo "Cleaning up old builds...\n"
rm -rf asyngular-client.js asyngular-client.min.js
rm -rf socketcluster-client.js socketcluster-client.min.js
echo "Browser Release:"
gulp browserify
gulp minify
10 changes: 5 additions & 5 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@ var VERSION = require('./package.json').version;
// declaration added by browserify.
var FULL_HEADER = (
'/**\n' +
' * Asyngular JavaScript client v' + VERSION + '\n' +
' * SocketCluster JavaScript client v' + VERSION + '\n' +
' */\n '
);

gulp.task('browserify', function (done) {
var stream = browserify({
builtins: ['_process', 'events', 'buffer', 'querystring'],
entries: 'index.js',
standalone: 'asyngularClient'
standalone: 'socketClusterClient'
})
.ignore('_process')
.require('./index.js', {
expose: 'asyngular-client'
expose: 'socketcluster-client'
})
.bundle();
return stream.pipe(source('asyngular-client.js'))
return stream.pipe(source('socketcluster-client.js'))
.pipe(insert.prepend(FULL_HEADER))
.pipe(convertNewline({
newline: 'lf',
Expand All @@ -43,7 +43,7 @@ gulp.task('browserify', function (done) {
});

gulp.task('minify', function () {
return gulp.src(DIST + 'asyngular-client.js')
return gulp.src(DIST + 'socketcluster-client.js')
.pipe(babel({
comments: false
}))
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const AGClientSocket = require('./lib/clientsocket');
const factory = require('./lib/factory');
const version = '6.2.4';
const version = '15.0.0';

module.exports.factory = factory;
module.exports.AGClientSocket = AGClientSocket;
Expand Down
6 changes: 3 additions & 3 deletions lib/clientsocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function AGClientSocket(socketOptions) {
AsyncStreamEmitter.call(this);

let defaultOptions = {
path: '/asyngular/',
path: '/socketcluster/',
secure: false,
autoConnect: true,
autoReconnect: true,
Expand All @@ -33,7 +33,7 @@ function AGClientSocket(socketOptions) {
ackTimeout: 10000,
timestampRequests: false,
timestampParam: 't',
authTokenName: 'asyngular.authToken',
authTokenName: 'socketcluster.authToken',
binaryType: 'arraybuffer',
batchOnHandshake: false,
batchOnHandshakeDuration: 100,
Expand Down Expand Up @@ -148,7 +148,7 @@ function AGClientSocket(socketOptions) {

if (this.options.protocol) {
let protocolOptionError = new InvalidArgumentsError(
'The "protocol" option does not affect asyngular-client - ' +
'The "protocol" option does not affect socketcluster-client - ' +
'If you want to utilize SSL/TLS, use "secure" option instead'
);
this._onError(protocolOptionError);
Expand Down
18 changes: 12 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "asyngular-client",
"description": "Asyngular JavaScript client",
"version": "6.2.4",
"homepage": "https://asyngular.io/",
"name": "socketcluster-client",
"description": "SocketCluster JavaScript client",
"version": "15.0.0",
"homepage": "https://socketcluster.io/",
"contributors": [
{
"name": "Jonathan Gros-Dubois",
Expand All @@ -11,12 +11,18 @@
],
"repository": {
"type": "git",
"url": "git://github.com/SocketCluster/asyngular-client.git"
"url": "git://github.com/SocketCluster/socketcluster-client.git"
},
"scripts": {
"build": "gulp browserify; gulp minify",
"test": "mocha --reporter spec --timeout 3000 --slow 3000"
},
"keywords": [
"websocket",
"realtime",
"client",
"socketcluster"
],
"dependencies": {
"ag-channel": "^4.0.2",
"ag-request": "^1.0.0",
Expand All @@ -39,7 +45,7 @@
"devDependencies": {
"@babel/core": "^7.7.4",
"@babel/preset-env": "^7.7.4",
"asyngular-server": "^6.2.0",
"socketcluster-server": "^15.0.0",
"babel-plugin-minify-dead-code-elimination": "^0.5.0",
"browserify": "^16.2.3",
"es-check": "^5.1.0",
Expand Down
57 changes: 34 additions & 23 deletions asyngular-client.js → socketcluster-client.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Asyngular JavaScript client v6.2.4
* SocketCluster JavaScript client v15.0.0
*/
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.asyngularClient = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.socketClusterClient = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
(function (global){
function AuthEngine() {
this._internalStorage = {};
Expand Down Expand Up @@ -88,7 +88,7 @@ function AGClientSocket(socketOptions) {
AsyncStreamEmitter.call(this);

let defaultOptions = {
path: '/asyngular/',
path: '/socketcluster/',
secure: false,
autoConnect: true,
autoReconnect: true,
Expand All @@ -97,7 +97,7 @@ function AGClientSocket(socketOptions) {
ackTimeout: 10000,
timestampRequests: false,
timestampParam: 't',
authTokenName: 'asyngular.authToken',
authTokenName: 'socketcluster.authToken',
binaryType: 'arraybuffer',
batchOnHandshake: false,
batchOnHandshakeDuration: 100,
Expand Down Expand Up @@ -212,7 +212,7 @@ function AGClientSocket(socketOptions) {

if (this.options.protocol) {
let protocolOptionError = new InvalidArgumentsError(
'The "protocol" option does not affect asyngular-client - ' +
'The "protocol" option does not affect socketcluster-client - ' +
'If you want to utilize SSL/TLS, use "secure" option instead'
);
this._onError(protocolOptionError);
Expand Down Expand Up @@ -3648,7 +3648,7 @@ function hexSlice (buf, start, end) {

var out = ''
for (var i = start; i < end; ++i) {
out += toHex(buf[i])
out += hexSliceLookupTable[buf[i]]
}
return out
}
Expand Down Expand Up @@ -4234,11 +4234,6 @@ function base64clean (str) {
return str
}

function toHex (n) {
if (n < 16) return '0' + n.toString(16)
return n.toString(16)
}

function utf8ToBytes (string, units) {
units = units || Infinity
var codePoint
Expand Down Expand Up @@ -4369,6 +4364,20 @@ function numberIsNaN (obj) {
return obj !== obj // eslint-disable-line no-self-compare
}

// Create lookup table for `toString('hex')`
// See: https://github.com/feross/buffer/issues/219
var hexSliceLookupTable = (function () {
var alphabet = '0123456789abcdef'
var table = new Array(256)
for (var i = 0; i < 16; ++i) {
var i16 = i * 16
for (var j = 0; j < 16; ++j) {
table[i16 + j] = alphabet[i] + alphabet[j]
}
}
return table
})()

}).call(this,require("buffer").Buffer)
},{"base64-js":10,"buffer":11,"ieee754":13}],12:[function(require,module,exports){
class ConsumableStream {
Expand Down Expand Up @@ -7570,14 +7579,16 @@ function bytesToUuid(buf, offset) {
var i = offset || 0;
var bth = byteToHex;
// join used to fix memory issue caused by concatenation: https://bugs.chromium.org/p/v8/issues/detail?id=3175#c4
return ([bth[buf[i++]], bth[buf[i++]],
bth[buf[i++]], bth[buf[i++]], '-',
bth[buf[i++]], bth[buf[i++]], '-',
bth[buf[i++]], bth[buf[i++]], '-',
bth[buf[i++]], bth[buf[i++]], '-',
bth[buf[i++]], bth[buf[i++]],
bth[buf[i++]], bth[buf[i++]],
bth[buf[i++]], bth[buf[i++]]]).join('');
return ([
bth[buf[i++]], bth[buf[i++]],
bth[buf[i++]], bth[buf[i++]], '-',
bth[buf[i++]], bth[buf[i++]], '-',
bth[buf[i++]], bth[buf[i++]], '-',
bth[buf[i++]], bth[buf[i++]], '-',
bth[buf[i++]], bth[buf[i++]],
bth[buf[i++]], bth[buf[i++]],
bth[buf[i++]], bth[buf[i++]]
]).join('');
}

module.exports = bytesToUuid;
Expand Down Expand Up @@ -7634,7 +7645,7 @@ var _clockseq;
var _lastMSecs = 0;
var _lastNSecs = 0;

// See https://github.com/broofa/node-uuid for API details
// See https://github.com/uuidjs/uuid for API details
function v1(options, buf, offset) {
var i = buf && offset || 0;
var b = buf || [];
Expand Down Expand Up @@ -8045,10 +8056,10 @@ class WritableConsumableStream extends ConsumableStream {

module.exports = WritableConsumableStream;

},{"./consumer":30,"consumable-stream":12}],"asyngular-client":[function(require,module,exports){
},{"./consumer":30,"consumable-stream":12}],"socketcluster-client":[function(require,module,exports){
const AGClientSocket = require('./lib/clientsocket');
const factory = require('./lib/factory');
const version = '6.2.4';
const version = '15.0.0';

module.exports.factory = factory;
module.exports.AGClientSocket = AGClientSocket;
Expand All @@ -8059,5 +8070,5 @@ module.exports.create = function (options) {

module.exports.version = version;

},{"./lib/clientsocket":2,"./lib/factory":3}]},{},["asyngular-client"])("asyngular-client")
},{"./lib/clientsocket":2,"./lib/factory":3}]},{},["socketcluster-client"])("socketcluster-client")
});
4 changes: 4 additions & 0 deletions socketcluster-client.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit 4830adc

Please sign in to comment.