Compare commits

..

4 Commits

Author SHA1 Message Date
c390881a4e 1.1.56 2019-11-08 17:31:04 +01:00
5e64f4ca25 fix(core): update 2019-11-08 17:31:04 +01:00
765bc73197 1.1.55 2019-11-08 17:11:41 +01:00
105acaf97b fix(core): update 2019-11-08 17:11:41 +01:00
5 changed files with 11 additions and 7 deletions

2
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartsocket",
"version": "1.1.54",
"version": "1.1.56",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

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

View File

@@ -1,3 +1,5 @@
export interface IRequestAuthPayload {
serverShortId: string;
}
}
export type TConnectionEvent = 'terminated' | 'error';

View File

@@ -33,7 +33,7 @@ export class SmartsocketClient {
public serverPort: number;
public autoReconnect: boolean;
public eventSubject = new plugins.smartrx.rxjs.Subject();
public eventSubject = new plugins.smartrx.rxjs.Subject<interfaces.TConnectionEvent>();
public socketFunctions = new plugins.lik.Objectmap<SocketFunction<any>>();
public socketRequests = new plugins.lik.Objectmap<SocketRequest<any>>();
@@ -135,6 +135,7 @@ export class SmartsocketClient {
}
defaultLogger.log('warn', `disconnected from server ${this.remoteShortId}`);
this.remoteShortId = null;
this.eventSubject.next('terminated');
if (this.autoReconnect) {
this.tryDebouncedReconnect();

View File

@@ -55,7 +55,7 @@ export class SocketConnection {
public smartsocketRef: Smartsocket | SmartsocketClient;
public socket: SocketIO.Socket | SocketIOClient.Socket;
public eventSubject = new plugins.smartrx.rxjs.Subject();
public eventSubject = new plugins.smartrx.rxjs.Subject<interfaces.TConnectionEvent>();
constructor(optionsArg: ISocketConnectionConstructorOptions) {
this.alias = optionsArg.alias;
@@ -67,12 +67,12 @@ export class SocketConnection {
// standard behaviour that is always true
allSocketConnections.add(this);
this.socket.on('disconnect', () => {
this.socket.on('disconnect', async () => {
plugins.smartlog.defaultLogger.log(
'info',
`SocketConnection with >alias ${this.alias} on >side ${this.side} disconnected`
);
this.socket.disconnect();
await this.disconnect();
allSocketConnections.remove(this);
});
}
@@ -173,5 +173,6 @@ export class SocketConnection {
// disconnecting ----------------------
public async disconnect() {
this.socket.disconnect(true);
this.eventSubject.next('terminated');
}
}