@ex-master/core
Advanced tools
Comparing version 0.2.5 to 0.2.6
@@ -18,3 +18,3 @@ import { BehaviorSubject, Subject } from 'rxjs'; | ||
constructor(address: string, options?: WebSocketConnectionOptions<TMessage>); | ||
send(message: object): Promise<boolean>; | ||
send(message: object | string): Promise<boolean>; | ||
close(): void; | ||
@@ -21,0 +21,0 @@ terminate(): void; |
@@ -90,3 +90,3 @@ "use strict"; | ||
return new Promise(resolve => { | ||
this.socket.send(JSON.stringify(message), error => { | ||
this.socket.send(typeof message === 'string' ? message : JSON.stringify(message), error => { | ||
if (error) { | ||
@@ -93,0 +93,0 @@ if (this.socket.readyState !== ws_1.default.OPEN) { |
{ | ||
"name": "@ex-master/core", | ||
"version": "0.2.5", | ||
"version": "0.2.6", | ||
"main": "bld/library/index.js", | ||
@@ -29,3 +29,3 @@ "types": "bld/library/index.d.ts", | ||
}, | ||
"gitHead": "a6e8a3c8823b172db5bb4aa79320b5f5465667c6" | ||
"gitHead": "99951d234a40eb8c520151412842be2c13b8cacf" | ||
} |
@@ -135,3 +135,3 @@ import {Agent as HttpsAgent} from 'https'; | ||
async send(message: object): Promise<boolean> { | ||
async send(message: object | string): Promise<boolean> { | ||
if (this.status$.value !== 'open') { | ||
@@ -144,14 +144,17 @@ throw new Error( | ||
return new Promise<boolean>(resolve => { | ||
this.socket!.send(JSON.stringify(message), error => { | ||
if (error) { | ||
if (this.socket!.readyState !== WebSocket.OPEN) { | ||
this.socket!.terminate(); | ||
this.socket!.send( | ||
typeof message === 'string' ? message : JSON.stringify(message), | ||
error => { | ||
if (error) { | ||
if (this.socket!.readyState !== WebSocket.OPEN) { | ||
this.socket!.terminate(); | ||
} | ||
resolve(false); | ||
return; | ||
} | ||
resolve(false); | ||
return; | ||
} | ||
resolve(true); | ||
}); | ||
resolve(true); | ||
}, | ||
); | ||
}); | ||
@@ -158,0 +161,0 @@ } |
Sorry, the diff of this file is not supported yet
122196
2508