Add Executor and RelaySet
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import type {Relay} from './Relay'
|
||||
import {EventBus} from './util/EventBus'
|
||||
|
||||
export class RelaySet {
|
||||
relays: Relay[]
|
||||
bus: EventBus
|
||||
constructor(relays) {
|
||||
this.relays = relays
|
||||
this.bus = new EventBus()
|
||||
|
||||
relays.forEach(relay => {
|
||||
relay.bus.pipe(EventBus.ANY, this.bus)
|
||||
})
|
||||
}
|
||||
send(...payload) {
|
||||
this.relays.forEach(async relay => {
|
||||
await relay.connect()
|
||||
|
||||
if (relay.status === Relay.STATUS.READY) {
|
||||
relay.send(...payload)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user