Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Communications Backbone System
backbone-adapter-javascript
Commits
96722a8d
Unverified
Commit
96722a8d
authored
2 years ago
by
Dan Jones
Browse files
Options
Download
Email Patches
Plain Diff
feat: initial work to support socket mode
parent
6f12efac
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
4 deletions
+26
-4
src/adapter/index.js
src/adapter/index.js
+26
-4
No files found.
src/adapter/index.js
View file @
96722a8d
...
...
@@ -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
);
});
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment