Skip to content
Snippets Groups Projects
Verified Commit 936a5332 authored by Volker Schukai's avatar Volker Schukai :alien:
Browse files

fix: check socket state

parent dc8addf1
No related branches found
No related tags found
No related merge requests found
......@@ -231,14 +231,15 @@ class WebSocketDatasource extends Datasource {
/**
* @return {Promise}
* @throws {Error} the options does not contain a valid json definition
* @throws {Error} the data cannot be read
* @throws {TypeError} value is not an object
*/
read() {
const self = this;
let response;
if (self[connectionSymbol].socket||self[connectionSymbol].socket.readyState!==1) {
return Promise.reject('The connection is not established.');
}
return new Promise((resolve, reject) => {
if (self[receiveQueueSymbol].isEmpty()) {
resolve();
......@@ -291,6 +292,10 @@ class WebSocketDatasource extends Datasource {
write() {
const self = this;
if (self[connectionSymbol].socket||self[connectionSymbol].socket.readyState!==1) {
return Promise.reject('The connection is not established.');
}
let obj = self.get();
let transformation = self.getOption('write.mapping.transformer');
if (transformation !== undefined) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment