This commit is contained in:
ntr committed 2022-09-11 21:16:33 +10:00
1 parent 111f690482
commit 2c66c47163
14 files changed
+168 -58

No files matched your search

+6
View File
@@ -12,10 +12,12 @@ export enum Events {
WantAdded = 'WantAdded',
StartupSync = 'StartupSync',
ListingsUpdated = 'ListingsUpdated',
Connection = 'Connection',
}
export default function createEvents(log: Log, pg: Pg, discogs, offers) {
const events = new EventEmitter({ captureRejections: true });
const connections = new Map();
async function populateListings(want: Want) {
try {
@@ -82,5 +84,9 @@ export default function createEvents(log: Log, pg: Pg, discogs, offers) {
log.info('offers up to date');
});
events.on(Events.Connection, async function onConnection({ ws, id }) {
connections.set(id, ws);
})
return events;
}