diff --git a/examples/create-keys.ts b/examples/create-keys.ts deleted file mode 100644 index 2063e7a..0000000 --- a/examples/create-keys.ts +++ /dev/null @@ -1,10 +0,0 @@ -import {createCertificate} from "pem"; - -createCertificate({days: 1, selfSigned: true}, (error, result) => { - if (error) { - console.error(error); - return; - } - - console.log(result); -}); diff --git a/examples/getting-started/pubsub.ts b/examples/getting-started/pubsub.ts deleted file mode 100644 index e2c539e..0000000 --- a/examples/getting-started/pubsub.ts +++ /dev/null @@ -1,42 +0,0 @@ -import {Session, Channel, createChannel} from "better-sse"; - -class PubSub { - private events = new Map(); - - subscribe(session: Session, event: string): void { - if (!this.events.has(event)) { - const newChannel = createChannel(); - - this.events.set(event, newChannel); - - // Clean up channel if no more subscribers - newChannel.on("session-deregistered", () => { - if (newChannel.sessionCount === 0) { - this.events.delete(event); - } - }); - } - - const channel = this.events.get(event) as Channel; - - channel.register(session); - } - - unsubscribe(session: Session, event: string): void { - const channel = this.events.get(event); - - if (channel) { - channel.deregister(session); - } - } - - publish(data: unknown, event: string): void { - const channel = this.events.get(event); - - if (channel) { - channel.broadcast(data, event); - } - } -} - -export {PubSub};