File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,7 +13,6 @@ import pkg from './package.json' with { type: 'json' }
1313export default class Extension {
1414 #bootstrap = null
1515 #category = null
16- #debug = false
1716 #demo = false
1817 #features = [ ]
1918 #functions = [ ]
@@ -39,7 +38,6 @@ export default class Extension {
3938 this . #publisher = new Publisher (
4039 ( ) => {
4140 return {
42- debug : this . #debug,
4341 mercure,
4442 }
4543 } ,
@@ -63,7 +61,6 @@ export default class Extension {
6361 )
6462 new Subscriber ( ( ) => {
6563 return {
66- debug : this . #debug,
6764 extension : this ,
6865 functions : this . #functions,
6966 mercure,
@@ -111,11 +108,6 @@ export default class Extension {
111108 return this
112109 }
113110
114- enableDebug ( ) {
115- this . #debug = true
116- return this
117- }
118-
119111 /**
120112 * @param {Boolean } demo - If the extension is a demonstration.
121113 * @returns {Extension } The updated extension instance.
Original file line number Diff line number Diff line change 11{
22 "name" : " talkops" ,
33 "description" : " TalkOps SDK" ,
4- "version" : " 2.8 .0" ,
4+ "version" : " 2.9 .0" ,
55 "author" : " bierdok" ,
66 "license" : " MIT" ,
77 "main" : " index.mjs" ,
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ export default class Publisher {
44 #useConfig = null
55 #useState = null
66 #lastEventState = null
7+ #lastPingAt = null
78
89 constructor ( useConfig , useState ) {
910 this . #useConfig = useConfig
@@ -32,9 +33,14 @@ export default class Publisher {
3233 this . publishEvent ( { type : 'state' , state : this . #useState( ) } )
3334 }
3435
36+ onPing ( ) {
37+ this . #lastPingAt = new Date ( ) . getTime ( )
38+ this . publishEvent ( { type : 'pong' } )
39+ }
40+
3541 async publishEvent ( event ) {
42+ if ( this . #lastPingAt && this . #lastPingAt < new Date ( ) . getTime ( ) - 6000 ) return
3643 const config = this . #useConfig( )
37- config . debug && console . log ( 'pub' , event . type )
3844 await axios . post (
3945 config . mercure . url ,
4046 new URLSearchParams ( {
Original file line number Diff line number Diff line change @@ -27,7 +27,9 @@ export default class Subscriber {
2727
2828 async #onEvent( event ) {
2929 const config = this . #useConfig( )
30- config . debug && console . log ( 'sub' , event . type )
30+ if ( event . type === 'ping' ) {
31+ config . publisher . onPing ( )
32+ }
3133 if ( event . type === 'boot' ) {
3234 for ( const name of Object . keys ( event . parameters ) ) {
3335 for ( const parameter of config . parameters ) {
You can’t perform that action at this time.
0 commit comments