Unverified Commit 96722a8d authored by Dan Jones's avatar Dan Jones
Browse files

feat: initial work to support socket mode

parent 6f12efac
......@@ -125,6 +125,10 @@ export class Adapter {
});
}
getMode() {
return ('mode' in this.config) ? this.config.mode : 'http';
}
/**
* Publish a message to the backbone with the specified topic
*
......@@ -134,7 +138,16 @@ export class Adapter {
* @param {boolean} is_retry
* @returns
*/
publish(topic, body, is_retry = false) {
publish(topic, body) {
let mode = self.getMode();
let response;
switch (mode) {
case 'http': response = this.http_publish(topic, body); break;
}
return response;
}
http_publish(topic, body, is_retry = false) {
let adapterConfig = this.config;
return this.getAuthorizationHeader()
.then((headers) => {
......@@ -165,7 +178,7 @@ export class Adapter {
retry = true;
}
}
if (retry && !is_retry) return this.publish(topic, body, true);
if (retry && !is_retry) return this.http_publish(topic, body, true);
else return Promise.reject(error);
});
}
......@@ -182,7 +195,16 @@ export class Adapter {
* @param {boolean} is_retry
* @returns
*/
broadcast(body, is_retry = false) {
broadcast(body) {
let mode = self.getMode();
let response;
switch (mode) {
case 'http': response = this.http_broadcast(body); break;
}
return response;
}
http_broadcast(body, is_retry = false) {
let adapterConfig = this.config;
return this.getAuthorizationHeader()
.then((headers) => {
......@@ -212,7 +234,7 @@ export class Adapter {
retry = true;
}
}
if (retry && !is_retry) return this.broadcast(body, true);
if (retry && !is_retry) return this.http_broadcast(body, true);
else return Promise.reject(error);
});
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment