Skip to content

Browser notifications for PlanetSide 2 alerts 🚨

License

Notifications You must be signed in to change notification settings

dbrennand/PS2Alert.me

Repository files navigation

🚨 PS2Alert.me

Browser notifications for PlanetSide 2 alerts.

Introduction

PS2Alert.me allows a user to receive push notifications for PlanetSide 2 alerts in their browser. The application achieves this by leveraging Service Workers, the IndexedDB API, Web Storage API, Push API, Notifications API and Push Services.

Components

The project has several components:

  1. Web application (frontend - PS2Alert.me):

    • Users select the PlanetSide 2 server(s) to subscribe to alert notifications for and a Service Worker is registered to receive push notifications.
  2. MongoDB (Backend):

    • A user's chosen server(s) to subscribe to alert notifications for and subscription data (forming the Notify model) are stored in the database.

    • The web application and consumer interact with the database. Adding and removing Notify documents and retrieving them respectively.

  3. RabbitMQ (Backend):

    • A messaging broker where MetagameEvents (alerts) are sent from the publisher to a queue which is then consumed.
  4. Publisher (Backend):

    • Connects to the PlanetSide 2 WebSocket Event Stream and listens for MetagameEvents. When a MetagameEvent has the property started, the publisher sends the MetagameEvent to the queue.
  5. Consumer (Backend):

    • Watches the RabbitMQ queue for MetagameEvents. When a MetagameEvent occurs in the queue, find all Notify documents that are subscribed to push notifications for the server which the MetagameEvent is occurring on and send a push notification to each.

The following image provides a high level overview of the PS2Alert.me components and how they interact with one another to send a push notification.

How does PS2Alert.me send a push notification and what data is stored/collected?

The process of subscribing to push notifications is as follows:

  1. A Service Worker is registered in the browser. The Service Worker is responsible for:

    • Saving subscription data in the browser (more on this below).

    • Handling incoming push notifications from a push service.

  2. The chosen server(s) are retrieved and a subscription is created. The subscription contains an endpoint and encryption keys for sending a push notification securely.

  3. The subscription data is saved in the browser using IndexedDB to handle future subscription updates. Details on this can be found in #3.

  4. The chosen server(s) and subscription data are then sent to PS2Alert.me in JSON format:

    {"subscription": {
        "keys": {
            "