File tree Expand file tree Collapse file tree 2 files changed +30
-11
lines changed Expand file tree Collapse file tree 2 files changed +30
-11
lines changed Original file line number Diff line number Diff line change 88 "ts-node" : " >= 0"
99 },
1010 "scripts" : {
11+ "build" : " cd .. && pnpm build && cd ./examples && pnpm install" ,
1112 "majordomo" : " ts-node ./majordomo/index.ts" ,
1213 "queue" : " ts-node ./queue/index.ts" ,
1314 "threaded-worker" : " ts-node ./threaded-worker/index.ts" ,
Original file line number Diff line number Diff line change 1+ /* eslint-disable */
12const zmq = require ( "zeromq/v5-compat" )
23
3- const pub = zmq . socket ( "pub" )
4- const sub = zmq . socket ( "sub" )
4+ function main ( ) {
5+ const pub = zmq . socket ( "pub" )
6+ const sub = zmq . socket ( "sub" )
57
6- pub . bind ( "tcp://*:3456" , err => {
7- if ( err ) {
8- throw err
9- }
8+ pub . on ( "bind" , address => {
9+ console . log ( `Bound to ${ address } ` )
10+ } )
11+
12+ pub . bind ( "tcp://127.0.0.1:3456" , err => {
13+ if ( err ) {
14+ throw err
15+ }
1016
11- sub . connect ( "tcp://127.0.0.1:3456" )
17+ sub . connect ( "tcp://127.0.0.1:3456" )
18+ console . log ( "Subscriber connected to tcp://127.0.0.1:3456" )
1219
13- pub . send ( "message" )
20+ sub . on ( "message" , msg => {
21+ // Handle received message...
22+ console . log ( `Received message: ${ msg . toString ( ) } ` )
23+ } )
1424
15- sub . on ( "message" , msg => {
16- // Handle received message...
25+ pub . send ( "message" )
1726 } )
18- } )
27+
28+ if ( process . env . CI ) {
29+ // exit after 1 second in CI environment
30+ setTimeout ( ( ) => {
31+ process . exit ( 0 )
32+ } , 2000 )
33+ }
34+ }
35+
36+ main ( )
You can’t perform that action at this time.
0 commit comments