Compare commits

...

8 Commits

5 changed files with 332 additions and 606 deletions

913
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartsocket",
"version": "1.1.69",
"version": "1.2.1",
"description": "easy and secure websocket communication",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",

View File

@ -1,11 +1,9 @@
// tslint:disable-next-line:no-implicit-dependencies
import { expect, tap } from '@pushrocks/tapbundle';
import * as smarthash from '@pushrocks/smarthash';
import * as smartpromise from '@pushrocks/smartpromise';
import * as isohash from '@pushrocks/isohash';
import * as smartexpress from '@pushrocks/smartexpress';
import socketIoClient = require('socket.io-client');
import smartsocket = require('../ts/index');
let testSmartsocket: smartsocket.Smartsocket;
@ -15,7 +13,7 @@ let testSocketFunction1: smartsocket.SocketFunction<any>;
let myseServer: smartexpress.Server;
const testConfig = {
port: 3005,
port: 3000,
};
// class smartsocket
@ -40,7 +38,7 @@ tap.test('Should accept an smartExpressServer as server', async () => {
tap.test('should add a socketrole', async () => {
testSocketRole1 = new smartsocket.SocketRole({
name: 'testRole1',
passwordHash: smarthash.sha256FromStringSync('testPassword'),
passwordHash: await isohash.sha256FromString('testPassword'),
});
testSmartsocket.addSocketRoles([testSocketRole1]);
});

View File

@ -1,11 +1,8 @@
// tslint:disable-next-line:no-implicit-dependencies
import { expect, tap } from '@pushrocks/tapbundle';
import * as smarthash from '@pushrocks/smarthash';
import * as smartpromise from '@pushrocks/smartpromise';
import socketIoClient = require('socket.io-client');
import smartsocket = require('../ts/index');
import * as isohash from '@pushrocks/isohash';
let testSmartsocket: smartsocket.Smartsocket;
let testSmartsocketClient: smartsocket.SmartsocketClient;
@ -48,7 +45,7 @@ tap.test('should create a new smartsocket', async () => {
tap.test('should add a socketrole', async () => {
testSocketRole1 = new smartsocket.SocketRole({
name: 'testRole1',
passwordHash: smarthash.sha256FromStringSync('testPassword'),
passwordHash: await isohash.sha256FromString('testPassword'),
});
testSmartsocket.addSocketRoles([testSocketRole1]);
});

View File

@ -163,6 +163,14 @@ export class SmartsocketClient {
}
}
/**
* stops the client completely
*/
public async stop() {
this.autoReconnect = false;
await this.disconnect();
}
/**
* try a reconnection
*/