Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
N
node-bigstream
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bs
node-bigstream
Commits
f9e18d4b
Commit
f9e18d4b
authored
May 21, 2023
by
Kamron Aroonrua
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
http emit
parent
902bbdd9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
3 deletions
+13
-3
main.js
http-listener/main.js
+10
-1
service-main.js
http-listener/ws/service-main.js
+3
-2
No files found.
http-listener/main.js
View file @
f9e18d4b
...
...
@@ -11,6 +11,8 @@ var EvenPub = ctx.getLib('lib/amqp/event-pub');
var
QueueCaller
=
ctx
.
getLib
(
'lib/amqp/queuecaller'
);
var
EvenSub
=
ctx
.
getLib
(
'lib/amqp/event-sub'
);
const
EventEmitter
=
require
(
'events'
)
const
JOBCHANEL
=
'bs_job_cmd'
;
const
API_PORT
=
19180
;
...
...
@@ -27,6 +29,7 @@ function HTTPListener(cfg)
this
.
jobcaller
=
new
QueueCaller
({
'url'
:
this
.
config
.
amqp
.
url
,
'name'
:
'bs_jobs_cmd'
});
this
.
evs
=
new
EvenSub
({
'url'
:
this
.
config
.
amqp
.
url
,
'name'
:
'bs_trigger_cmd'
});
this
.
msgrecv
=
new
EvenSub
({
'url'
:
this
.
config
.
amqp
.
url
,
'name'
:
'bs_msg_bus'
});
this
.
httpcb
=
new
EventEmitter
()
}
HTTPListener
.
prototype
.
start
=
function
()
...
...
@@ -40,6 +43,11 @@ HTTPListener.prototype._http_start = function()
{
var
self
=
this
;
self
.
msgrecv
.
sub
(
'msg.httpcb.#'
+
session_id
,
function
(
err
,
msg
){
var
ssid
=
msg
.
topic
.
split
(
'.'
)[
2
]
self
.
httpcb
.
emit
(
ssid
,
msg
)
})
this
.
httpacl
.
update
(
function
(
err
){
if
(
!
err
){
console
.
log
(
'WWW:ACL Update
\
t
\
t[OK]'
);
...
...
@@ -62,7 +70,8 @@ HTTPListener.prototype._http_start = function()
app
.
use
(
context
.
middleware
({
'httpacl'
:
self
.
httpacl
,
'jobcaller'
:
self
.
jobcaller
,
'msgrecv'
:
self
.
msgrecv
'msgrecv'
:
self
.
msgrecv
,
'httpcb'
:
self
.
httpcb
}));
app
.
use
(
require
(
'./ws'
));
...
...
http-listener/ws/service-main.js
View file @
f9e18d4b
...
...
@@ -22,6 +22,7 @@ var process_req = function(req, res ,method) {
//var evp = req.context.evp;
var
jobcaller
=
req
.
context
.
jobcaller
;
var
msgrecv
=
req
.
context
.
msgrecv
;
var
httpcb
=
req
.
context
.
httpcb
;
var
j
=
httpacl
.
findJob
(
appkey
,
method
);
var
jmatch
=
(
j
.
length
>
0
);
...
...
@@ -83,8 +84,8 @@ var process_req = function(req, res ,method) {
if
(
jmatch
)
{
if
(
cb_response
){
msgrecv
.
sub
(
'msg.httpcb.'
+
session_id
,
function
(
err
,
msg
){
resp_msg
.
response
=
msg
.
data
httpcb
.
on
(
session_id
,
function
(
msg
){
resp_msg
.
response
=
msg
.
data
.
data
;
respHelper
.
responseOK
(
resp_msg
);
})
}
else
{
...
...
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